public class ChildCommandElementExecutor extends CommandElement implements CommandExecutor
| Constructor and Description |
|---|
ChildCommandElementExecutor(CommandExecutor fallbackExecutor)
Deprecated.
Use the other constructor instead. Note: this entire system
will be replaced in API 8.
|
ChildCommandElementExecutor(CommandExecutor fallbackExecutor,
CommandElement fallbackElements,
boolean fallbackOnFail)
Create a new combined argument element and executor to handle the
parsing and execution of child commands.
|
| Modifier and Type | Method and Description |
|---|---|
List<String> |
complete(CommandSource src,
CommandArgs args,
CommandContext context)
Fetch completions for command arguments.
|
CommandResult |
execute(CommandSource src,
CommandContext args)
Callback for the execution of a command.
|
Text |
getUsage(CommandSource src)
Return a usage message for this specific argument.
|
void |
parse(CommandSource source,
CommandArgs args,
CommandContext context)
Attempt to extract a value for this element from the given arguments and
put it in the given context.
|
protected Object |
parseValue(CommandSource source,
CommandArgs args)
Attempt to extract a value for this element from the given arguments.
|
Optional<CommandMapping> |
register(CommandCallable callable,
List<String> aliases)
Register a child command for a given set of aliases.
|
Optional<CommandMapping> |
register(CommandCallable callable,
String... aliases)
Register a child command for a given set of aliases.
|
getKey, getUntranslatedKey@Deprecated public ChildCommandElementExecutor(@Nullable CommandExecutor fallbackExecutor)
fallbackExecutor - The executor to execute if the child command
has been marked optional (Generally when this is wrapped in a
GenericArguments.optional(CommandElement)public ChildCommandElementExecutor(@Nullable CommandExecutor fallbackExecutor, @Nullable CommandElement fallbackElements, boolean fallbackOnFail)
fallbackExecutor - The executor to execute if the child command
has been marked optional (Generally when this is wrapped in a
GenericArguments.optional(CommandElement)fallbackElements - The alternate CommandElements that should
be parsed if a child element fails to be parsedfallbackOnFail - If true, then if a child command cannot parse the
elements, the exception is discarded and the parent command attempts
to parse the elements. If false, a child command will not pass
control back to the parent, displaying its own exception messagepublic Optional<CommandMapping> register(CommandCallable callable, List<String> aliases)
callable - The command to registeraliases - The aliases to register it aspublic Optional<CommandMapping> register(CommandCallable callable, String... aliases)
callable - The command to registeraliases - The aliases to register it aspublic List<String> complete(CommandSource src, CommandArgs args, CommandContext context)
CommandElementcomplete in class CommandElementsrc - The source requesting tab completionsargs - The arguments currently providedcontext - The context to store state inpublic void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException
CommandElementCommandElement.parseValue(CommandSource, CommandArgs) for getting the values.
This method is expected to have no side-effects for the source, meaning
that executing it will not change the state of the CommandSource
in any way.parse in class CommandElementsource - The source to parse forargs - The args to extract fromcontext - The context to supply toArgumentParseException - if unable to extract a valueprotected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException
CommandElementCommandSource
in any way.parseValue in class CommandElementsource - The source to parse forargs - the argumentsArgumentParseException - if unable to extract a valuepublic CommandResult execute(CommandSource src, CommandContext args) throws CommandException
CommandExecutorexecute in interface CommandExecutorsrc - The commander who is executing this commandargs - The parsed command arguments for this commandCommandException - If a user-facing error occurs while
executing this commandpublic Text getUsage(CommandSource src)
CommandElementgetUsage in class CommandElementsrc - The source requesting usage