public interface CommandCallable
CommandSpec
.
Implementations are not required to implement a sane
Object.equals(Object)
but really should.
Modifier and Type | Method and Description |
---|---|
Optional<Text> |
getHelp(CommandSource source)
Gets a longer formatted help message about this command.
|
Optional<Text> |
getShortDescription(CommandSource source)
Gets a short one-line description of this command.
|
List<String> |
getSuggestions(CommandSource source,
String arguments,
Location<World> targetPosition)
Gets a list of suggestions based on input.
|
Text |
getUsage(CommandSource source)
Gets the usage string of this command.
|
CommandResult |
process(CommandSource source,
String arguments)
Execute the command based on input arguments.
|
boolean |
testPermission(CommandSource source)
Test whether this command can probably be executed by the given source.
|
CommandResult process(CommandSource source, String arguments) throws CommandException
The implementing class must perform the necessary permission checks.
source
- The caller of the commandarguments
- The raw arguments for this commandCommandException
- Thrown on a command errorList<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) throws CommandException
If a suggestion is chosen by the user, it will replace the last word.
source
- The command sourcearguments
- The arguments entered up to this pointtargetPosition
- The position the source is looking at when
performing tab completionCommandException
- Thrown if there was a parsing errorboolean testPermission(CommandSource source)
If implementations are unsure if the command can be executed by
the source, true
should be returned. Return values of this method
may be used to determine whether this command is listed in command
listings.
source
- The caller of the commandOptional<Text> getShortDescription(CommandSource source)
The help system may display the description in the command list.
source
- The source of the help requestOptional<Text> getHelp(CommandSource source)
It is recommended to use the default text color and style. Sections with text actions (e.g. hyperlinks) should be underlined.
Multi-line messages can be created by separating the lines with
\n
.
The help system may display this message when a source requests detailed information about a command.
source
- The source of the help requestText getUsage(CommandSource source)
A usage string may look like
[-w <world>] <var1> <var2>
.
The string must not contain the command alias.
source
- The source of the help request