public final class CommandSpec extends Object implements CommandCallable
| Modifier and Type | Class and Description |
|---|---|
static class |
CommandSpec.Builder
Builder for command specs.
|
| Modifier and Type | Method and Description |
|---|---|
static CommandSpec.Builder |
builder()
Return a new builder for a CommandSpec.
|
void |
checkPermission(CommandSource source)
Check the relevant permission for this command with the provided source,
throwing an exception if the source does not have permission to use
the command.
|
List<String> |
complete(CommandSource source,
CommandArgs args,
CommandContext context)
Return tab completion results using the existing parsed arguments and
context.
|
boolean |
equals(Object o) |
CommandExecutor |
getExecutor()
Gets the active executor for this command.
|
Optional<Text> |
getExtendedDescription(CommandSource source)
Gets the extended description used with this command if any is present.
|
Optional<Text> |
getHelp(CommandSource source)
Return a longer description for this command.
|
InputTokenizer |
getInputTokenizer()
Gets the active input tokenizer used for this command.
|
Optional<Text> |
getShortDescription(CommandSource source)
Gets a short, one-line description used with this command if any is
present.
|
List<String> |
getSuggestions(CommandSource source,
String arguments,
Location<World> targetPos)
Gets a list of suggestions based on input.
|
Text |
getUsage(CommandSource source)
Gets the usage for this command appropriate for the provided command
source.
|
int |
hashCode() |
void |
populateContext(CommandSource source,
CommandArgs args,
CommandContext context)
Process this command with existing arguments and context objects.
|
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.
|
String |
toString() |
public static CommandSpec.Builder builder()
public void checkPermission(CommandSource source) throws CommandException
source - The source to checkCommandException - if the source does not have permissionpublic void populateContext(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException
source - The source to populate the context withargs - The arguments to process withcontext - The context to put data inArgumentParseException - if an invalid argument is providedpublic List<String> complete(CommandSource source, CommandArgs args, CommandContext context)
source - The source to parse arguments forargs - The arguments objectcontext - The context objectpublic CommandExecutor getExecutor()
public InputTokenizer getInputTokenizer()
public CommandResult process(CommandSource source, String arguments) throws CommandException
CommandCallableThe implementing class must perform the necessary permission checks.
process in interface CommandCallablesource - The caller of the commandarguments - The raw arguments for this commandCommandException - Thrown on a command errorpublic List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPos) throws CommandException
CommandCallableIf a suggestion is chosen by the user, it will replace the last word.
getSuggestions in interface CommandCallablesource - The command sourcearguments - The arguments entered up to this pointtargetPos - The position the source is looking at when
performing tab completionCommandException - Thrown if there was a parsing errorpublic boolean testPermission(CommandSource source)
CommandCallableIf 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.
testPermission in interface CommandCallablesource - The caller of the commandpublic Optional<Text> getShortDescription(CommandSource source)
getShortDescription in interface CommandCallablesource - The source of the help requestpublic Optional<Text> getExtendedDescription(CommandSource source)
source - The source to get the description forpublic Text getUsage(CommandSource source)
getUsage in interface CommandCallablesource - The sourcepublic Optional<Text> getHelp(CommandSource source)
getHelp in interface CommandCallablesource - The source to get the extended description for