Executes the command, returning its success @param sender Source object which is executing this command @param commandLabel The alias of the command used @param args All arguments passed to the command, split via ' ' @return true if the command was successful, otherwise false
(CommandSender sender, String commandLabel, String[] args)
| 25 | * @return true if the command was successful, otherwise false |
| 26 | */ |
| 27 | @Override |
| 28 | public boolean execute(CommandSender sender, String commandLabel, String[] args) { |
| 29 | boolean success = false; |
| 30 | |
| 31 | if (!owningPlugin.isEnabled()) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | if (!testPermission(sender)) { |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | try { |
| 40 | success = executor.onCommand(sender, this, commandLabel, args); |
| 41 | } catch (Throwable ex) { |
| 42 | throw new CommandException("Unhandled exception executing command '" + commandLabel + "' in plugin " + owningPlugin.getDescription().getFullName(), ex); |
| 43 | } |
| 44 | |
| 45 | if (!success && usageMessage.length() > 0) { |
| 46 | for (String line: usageMessage.replace("<command>", commandLabel).split("\n")) { |
| 47 | sender.sendMessage(line); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return success; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Sets the {@link CommandExecutor} to run when parsing this command |
nothing calls this directly
no test coverage detected