Throw errors if there is a error when doing the commands
This commit is contained in:
parent
c25519158a
commit
9b1ba66efc
@ -18,15 +18,19 @@ public class DisguiseCommand extends BaseDisguiseCommand {
|
|||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Disguise disguise = null;
|
||||||
try {
|
try {
|
||||||
Disguise disguise = parseDisguise(sender, args);
|
disguise = parseDisguise(sender, args);
|
||||||
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
|
||||||
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null && !ChatColor.getLastColors(ex.getMessage()).equals("")) {
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
|
} else {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
||||||
|
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,16 +23,20 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
|||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Disguise disguise;
|
||||||
try {
|
try {
|
||||||
Disguise disguise = parseDisguise(sender, args);
|
disguise = parseDisguise(sender, args);
|
||||||
listener.setSlap(sender.getName(), disguise);
|
|
||||||
sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise it as a "
|
|
||||||
+ disguise.getType().toReadable() + "!");
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null && !ChatColor.getLastColors(ex.getMessage()).equals("")) {
|
||||||
sender.sendMessage(ex.getMessage());
|
sender.sendMessage(ex.getMessage());
|
||||||
|
} else {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
listener.setSlap(sender.getName(), disguise);
|
||||||
|
sender.sendMessage(ChatColor.RED + "Right click a entity in the next 10 seconds to disguise it as a "
|
||||||
|
+ disguise.getType().toReadable() + "!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,20 +33,24 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
|
|||||||
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
sender.sendMessage(ChatColor.RED + "Cannot find the player '" + args[0] + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
String[] newArgs = new String[args.length - 1];
|
||||||
String[] newArgs = new String[args.length - 1];
|
for (int i = 0; i < newArgs.length; i++) {
|
||||||
for (int i = 0; i < newArgs.length; i++) {
|
newArgs[i] = args[i + 1];
|
||||||
newArgs[i] = args[i + 1];
|
|
||||||
}
|
|
||||||
Disguise disguise = parseDisguise(sender, newArgs);
|
|
||||||
DisguiseAPI.disguiseToAll(player, disguise);
|
|
||||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
|
||||||
+ disguise.getType().toReadable() + "!");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
if (ex.getMessage() != null) {
|
|
||||||
sender.sendMessage(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
DisguiseAPI.disguiseToAll(player, disguise);
|
||||||
|
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
||||||
|
+ disguise.getType().toReadable() + "!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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?");
|
sender.sendMessage(ChatColor.RED + "Limited radius to " + maxRadius + "! Don't want to make too much lag right?");
|
||||||
radius = maxRadius;
|
radius = maxRadius;
|
||||||
}
|
}
|
||||||
try {
|
String[] newArgs = new String[args.length - 1];
|
||||||
String[] newArgs = new String[args.length - 1];
|
for (int i = 0; i < newArgs.length; i++) {
|
||||||
for (int i = 0; i < newArgs.length; i++) {
|
newArgs[i] = args[i + 1];
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user