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