/** * Build a {@link CommandCallable} for the given method. * * @param object the object to be invoked on * @param method the method to invoke * @param definition the command definition annotation * @return the command executor * @throws ParametricException thrown on an error */ private CommandCallable build(Object object, Method method, Command definition) throws ParametricException { return new ParametricCallable(this, object, method, definition); }
@Override public Object call(String stringArguments, CommandLocals locals, String[] parentCommands) throws CommandException { if (parentCommands.length != 0 && !testPermission(locals)) { throw new CommandPermissionsException(); CommandContext context = new CommandContext(split, getValueFlags(), false, locals); parameter = parameters[i]; if (mayConsumeArguments(i, arguments)) { ArgumentStack usedArguments = getScopedContext(parameter, arguments); args[i] = getDefaultValue(i, arguments); args[i] = getDefaultValue(i, arguments); checkUnconsumed(arguments);
/** * Check to see if all arguments, including flag arguments, were consumed. * * @param scoped the argument scope * @throws UnconsumedParameterException thrown if parameters were not consumed */ private void checkUnconsumed(ContextArgumentStack scoped) throws UnconsumedParameterException { CommandContext context = scoped.getContext(); String unconsumed; String unconsumedFlags = getUnusedFlags(context); if ((unconsumed = scoped.getUnconsumed()) != null) { throw new UnconsumedParameterException(unconsumed + " " + unconsumedFlags); } if (unconsumedFlags != null) { throw new UnconsumedParameterException(unconsumedFlags); } }
parameter.setName(names.length > 0 ? names[i] : generateName(type, parameter.getClassifier(), i));