Interface Command
- 
- All Known Subinterfaces:
- Command.Parameterized,- Command.Raw
 
 public interface CommandThe Command interface is the low-level interface that all commands in the Sponge ecosystem inherit.Most plugins are highly recommended (but not obligated) to use builder()to create commands. TheCommand.Builderallows plugins to take advantage of a higher level of abstraction, such as argument parsers and simple child command handling, removing the need for boilerplate code. SuchCommand.Parameterizedcommands should register themselves during theRegisterCommandEvent<Command.Parameterized>event.Plugins that do not want to use the Command.Builderor any third-party command system should implement theCommand.Rawsub-interface instead. SuchCommand.Rawcommands should register themselves during theRegisterCommandEvent<Command.Raw>event.Plugins must not implement the Command.Parameterizedsub-interface themselves.Upon execution, commands are provided with a CommandCause, providing theCauseandEventContextthat invoked the command. See theCommandCausedocumentation for more information of the structure of this cause.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static interfaceCommand.BuilderA high levelCommand.Builderfor creating aCommand.Parameterized.static interfaceCommand.ParameterizedACommandthat has distinct steps for parsing arguments and executing a command based on those arguments.static interfaceCommand.RawA raw command that also contains aCommandTreeNodeto provide hints to the client for command completion.
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Command.Builderbuilder()Gets a builder for building aCommand.booleancanExecute(CommandCause cause)Test whether this command can probably be executed given thisCause.List<CommandCompletion>complete(CommandCause cause, ArgumentReader.Mutable arguments)Gets a list of completions based on input.Optional<Component>extendedDescription(CommandCause cause)Gets a longer formatted help message about this command.default Optional<Component>help(@NonNull CommandCause cause)Gets a longer formatted help message about this command.CommandResultprocess(CommandCause cause, ArgumentReader.Mutable arguments)Execute the command based on input arguments.Optional<Component>shortDescription(CommandCause cause)Gets a short one-line description of this command.Componentusage(CommandCause cause)Gets the usage string of this command.
 
- 
- 
- 
Method Detail- 
builderstatic Command.Builder builder() Gets a builder for building aCommand.- Returns:
- The Command.Builder
 
 - 
processCommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) throws CommandException Execute the command based on input arguments.The implementing class must perform the necessary permission checks. - Parameters:
- cause- The- CommandCauseof the invocation of command
- arguments- The raw arguments for this command
- Returns:
- The result of a command being processed
- Throws:
- CommandException- Thrown on a command error
 
 - 
completeList<CommandCompletion> complete(CommandCause cause, ArgumentReader.Mutable arguments) throws CommandException Gets a list of completions based on input.If a completion is chosen by the user, it will replace the last word. - Parameters:
- cause- The- CommandCauseof the command
- arguments- The arguments entered up to this point
- Returns:
- A list of suggestions
- Throws:
- CommandException- Thrown if there was a parsing error
 
 - 
canExecuteboolean canExecute(CommandCause cause) Test whether this command can probably be executed given thisCause.If implementations are unsure if the command can be executed by the source, trueshould be returned. Return values of this method may be used to determine whether this command is listed in command listings.- Parameters:
- cause- The- Causeto check
- Returns:
- Whether this command will execute
 
 - 
shortDescriptionOptional<Component> shortDescription(CommandCause cause) Gets a short one-line description of this command.The help system may display the description in the command list, or in any other function that displays a command list. It is therefore recommended that any description here is kept very short. - Parameters:
- cause- The- CommandCauseof the help request
- Returns:
- A description
- See Also:
- CommandRegistrar.shortDescription(CommandCause, CommandMapping)
 
 - 
extendedDescriptionOptional<Component> extendedDescription(CommandCause cause) Gets a longer formatted help message about this command.The help system may display this description when displaying details about this specific command. It should not contain the description provided by shortDescription(CommandCause).- Parameters:
- cause- The- Causeof the help request
- Returns:
- A description
 
 - 
helpdefault Optional<Component> help(@NonNull CommandCause cause) Gets a longer formatted help message about this command. This will typically comprise ofshortDescription(CommandCause)andextendedDescription(CommandCause)together.The help system may display this message when a source requests detailed information about a command. - Parameters:
- cause- The- Causeof the help request
- Returns:
- A help text
- See Also:
- CommandRegistrar.help(CommandCause, CommandMapping)
 
 - 
usageComponent usage(CommandCause cause) Gets the usage string of this command.A usage string may look like [<world>] <var1> <var2>.The string must not contain the command alias. - Parameters:
- cause- The- Causeof the help request
- Returns:
- A usage string
 
 
- 
 
-