Now able to set the max radius for disguiseradius and undisguiseradius
This commit is contained in:
parent
1c92c8c3e7
commit
5eca9c9d12
@ -2,3 +2,7 @@
|
|||||||
NotifyUpdate: true
|
NotifyUpdate: true
|
||||||
# Whats the permission to get the notification?
|
# Whats the permission to get the notification?
|
||||||
Permission: 'libsdisguises.update'
|
Permission: 'libsdisguises.update'
|
||||||
|
# Whats the max size allowed for command disguiseradius
|
||||||
|
DisguiseRadiusMax: 30
|
||||||
|
# Whats the max size allowed for command undisguiseradius
|
||||||
|
UndisguiseRadiusMax: 30
|
@ -19,6 +19,11 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class DisguiseRadiusCommand implements CommandExecutor {
|
public class DisguiseRadiusCommand implements CommandExecutor {
|
||||||
|
private int maxRadius = 30;
|
||||||
|
|
||||||
|
public DisguiseRadiusCommand(int maxRadius) {
|
||||||
|
this.maxRadius = maxRadius;
|
||||||
|
}
|
||||||
|
|
||||||
private ArrayList<String> allowedDisguises(CommandSender sender) {
|
private ArrayList<String> allowedDisguises(CommandSender sender) {
|
||||||
ArrayList<String> names = new ArrayList<String>();
|
ArrayList<String> names = new ArrayList<String>();
|
||||||
@ -75,9 +80,10 @@ public class DisguiseRadiusCommand implements CommandExecutor {
|
|||||||
if (allowedDisguises.contains(args[1].toLowerCase())) {
|
if (allowedDisguises.contains(args[1].toLowerCase())) {
|
||||||
// He can use the disguise huh.
|
// He can use the disguise huh.
|
||||||
int radius = Integer.parseInt(args[0]);
|
int radius = Integer.parseInt(args[0]);
|
||||||
if (radius > 30) {
|
if (radius > maxRadius) {
|
||||||
sender.sendMessage(ChatColor.RED + "Limited radius to 30! Don't want to make too much lag right?");
|
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius
|
||||||
radius = 30;
|
+ "! Don't want to make too much lag right?");
|
||||||
|
radius = maxRadius;
|
||||||
}
|
}
|
||||||
Disguise disguise = null;
|
Disguise disguise = null;
|
||||||
// Time to start constructing the disguise.
|
// Time to start constructing the disguise.
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||||
|
private int maxRadius = 30;
|
||||||
|
|
||||||
private boolean isNumeric(String string) {
|
private boolean isNumeric(String string) {
|
||||||
try {
|
try {
|
||||||
@ -20,6 +21,10 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UndisguiseRadiusCommand(int maxRadius) {
|
||||||
|
this.maxRadius = maxRadius;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
if (sender.getName().equals("CONSOLE")) {
|
if (sender.getName().equals("CONSOLE")) {
|
||||||
@ -27,7 +32,7 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (sender.hasPermission("libsdisguises.undisguiseradius")) {
|
if (sender.hasPermission("libsdisguises.undisguiseradius")) {
|
||||||
int radius = 30;
|
int radius = maxRadius;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (!isNumeric(args[0])) {
|
if (!isNumeric(args[0])) {
|
||||||
sender.sendMessage(ChatColor.RED + "Error! " + ChatColor.GREEN + args[0] + ChatColor.RED
|
sender.sendMessage(ChatColor.RED + "Error! " + ChatColor.GREEN + args[0] + ChatColor.RED
|
||||||
@ -35,6 +40,11 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
radius = Integer.parseInt(args[0]);
|
radius = Integer.parseInt(args[0]);
|
||||||
|
if (radius > maxRadius) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius
|
||||||
|
+ "! Don't want to make too much lag right?");
|
||||||
|
radius = maxRadius;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int disguisedEntitys = 0;
|
int disguisedEntitys = 0;
|
||||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||||
|
@ -220,6 +220,7 @@ public class LibsDisguises extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
saveDefaultConfig();
|
||||||
DisguiseListener listener = new DisguiseListener(this);
|
DisguiseListener listener = new DisguiseListener(this);
|
||||||
Bukkit.getPluginManager().registerEvents(listener, this);
|
Bukkit.getPluginManager().registerEvents(listener, this);
|
||||||
getCommand("disguise").setExecutor(new DisguiseCommand());
|
getCommand("disguise").setExecutor(new DisguiseCommand());
|
||||||
@ -228,9 +229,8 @@ public class LibsDisguises extends JavaPlugin implements Listener {
|
|||||||
getCommand("undisguiseplayer").setExecutor(new UndisguisePlayerCommand());
|
getCommand("undisguiseplayer").setExecutor(new UndisguisePlayerCommand());
|
||||||
getCommand("undisguiseentity").setExecutor(new UndisguiseEntityCommand(listener));
|
getCommand("undisguiseentity").setExecutor(new UndisguiseEntityCommand(listener));
|
||||||
getCommand("disguiseentity").setExecutor(new DisguiseEntityCommand(listener));
|
getCommand("disguiseentity").setExecutor(new DisguiseEntityCommand(listener));
|
||||||
getCommand("disguiseradius").setExecutor(new DisguiseRadiusCommand());
|
getCommand("disguiseradius").setExecutor(new DisguiseRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
||||||
getCommand("undisguiseradius").setExecutor(new UndisguiseRadiusCommand());
|
getCommand("undisguiseradius").setExecutor(new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax")));
|
||||||
saveDefaultConfig();
|
|
||||||
permission = getConfig().getString("Permission");
|
permission = getConfig().getString("Permission");
|
||||||
if (getConfig().getBoolean("NotifyUpdate")) {
|
if (getConfig().getBoolean("NotifyUpdate")) {
|
||||||
currentVersion = getDescription().getVersion();
|
currentVersion = getDescription().getVersion();
|
||||||
|
Loading…
Reference in New Issue
Block a user