Make the command execution throw an exception, and let's catch it.

This commit is contained in:
graywolf336 2014-01-21 11:22:26 -06:00
parent 9f34304fdb
commit 4c13948549
2 changed files with 9 additions and 3 deletions

View File

@ -27,5 +27,5 @@ public interface Command {
* @param args The args, in an array
* @return True if the method handled it in any way, false if we should send the usage message.
*/
public boolean execute(JailManager jm, CommandSender sender, String... args);
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception;
}

View File

@ -107,9 +107,15 @@ public class CommandHandler {
// Since everything has been checked and we're all clear, let's execute it.
// But if get back false, let's show the usage message.
if(!c.execute(jailmanager, sender, args)) {
try {
if(!c.execute(jailmanager, sender, args)) {
showUsage(sender, c);
return;
}
} catch (Exception e) {
e.printStackTrace();
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
showUsage(sender, c);
return;
}
}