@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { boolean result = false; for (Command command : commands) { result |= command.execute(sender, commandLabel, args); } return result; } }
/** * {@inheritDoc} */ public boolean dispatch(CommandSender sender, String commandLine) throws CommandException { String[] args = PATTERN_ON_SPACE.split(commandLine); if (args.length == 0) { return false; } String sentCommandLabel = args[0].toLowerCase(); Command target = getCommand(sentCommandLabel); if (target == null) { return false; } try { // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) target.execute(sender, sentCommandLabel, Arrays_copyOfRange(args, 1, args.length)); } catch (CommandException ex) { throw ex; } catch (Throwable ex) { throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex); } // return true as command was handled return true; }
@Override public boolean execute(CommandSender sender, String commandLabel, String[] args) { boolean result = false; for (Command command : commands) { result |= command.execute(sender, commandLabel, args); } return result; } }
@Override public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException { assertMainThread(); String[] commands = commandLine.split(" "); String commandLabel = commands[0]; String[] args = Arrays.copyOfRange(commands, 1, commands.length); Command command = getPluginCommand(commandLabel); if (command != null) return command.execute(sender, commandLabel, args); else return false; }
/** * Executes a command. * * @param command The command to execute. * @param sender The person that executed the command. * @param args The arguments to pass to the commands. * @return The value returned by {@link Command#execute}. */ public CommandResult execute(Command command, CommandSender sender, String... args) { assertMainThread(); if (!(sender instanceof MessageTarget)) { throw new IllegalArgumentException("Only a MessageTarget can be the sender of the command"); } boolean status = command.execute(sender, command.getName(), args); CommandResult result = new CommandResult(status, (MessageTarget) sender); return result; }
/** * {@inheritDoc} */ public boolean dispatch(CommandSender sender, String commandLine) throws CommandException { String[] args = PATTERN_ON_SPACE.split(commandLine); if (args.length == 0) { return false; } String sentCommandLabel = args[0].toLowerCase(); Command target = getCommand(sentCommandLabel); if (target == null) { return false; } try { target.timings.startTiming(); // Spigot // Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false) target.execute(sender, sentCommandLabel, Arrays_copyOfRange(args, 1, args.length)); target.timings.stopTiming(); // Spigot } catch (CommandException ex) { target.timings.stopTiming(); // Spigot throw ex; } catch (Throwable ex) { target.timings.stopTiming(); // Spigot throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex); } // return true as command was handled return true; }