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,10 +107,16 @@ 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.
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Command> getMatches(String command) {
|
||||
|
Loading…
Reference in New Issue
Block a user