Throw errors if there is a error when doing the commands

This commit is contained in:
Andrew
2013-11-19 00:50:39 +13:00
parent c25519158a
commit 9b1ba66efc
4 changed files with 56 additions and 41 deletions

View File

@@ -46,26 +46,29 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
radius = maxRadius;
}
try {
String[] newArgs = new String[args.length - 1];
for (int i = 0; i < newArgs.length; i++) {
newArgs[i] = args[i + 1];
}
Disguise disguise = parseDisguise(sender, newArgs);
// Time to use it!
int disguisedEntitys = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender)
continue;
DisguiseAPI.disguiseToAll(entity, disguise);
disguisedEntitys++;
}
sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!");
} catch (Exception ex) {
if (ex.getMessage() != null) {
sender.sendMessage(ex.getMessage());
}
String[] newArgs = new String[args.length - 1];
for (int i = 0; i < newArgs.length; i++) {
newArgs[i] = args[i + 1];
}
Disguise disguise;
try {
disguise = parseDisguise(sender, newArgs);
} catch (Exception ex) {
if (ex.getMessage() != null && !ChatColor.getLastColors(ex.getMessage()).equals("")) {
sender.sendMessage(ex.getMessage());
} else {
ex.printStackTrace();
}
return true;
} // Time to use it!
int disguisedEntitys = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender)
continue;
DisguiseAPI.disguiseToAll(entity, disguise);
disguisedEntitys++;
}
sender.sendMessage(ChatColor.RED + "Successfully disguised " + disguisedEntitys + " entities!");
return true;
}