Make the command execution throw an exception, and let's catch it.
This commit is contained in:
parent
9f34304fdb
commit
4c13948549
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user