Interface Command.Parameterized
- All Superinterfaces:
Command
- Enclosing interface:
Command
Command that has distinct steps for parsing arguments and
executing a command based on those arguments.
Plugins must not attempt to create their own instance of this
interface, and instead must use Command.builder() to do
so.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.command.Command
Command.Builder, Command.Parameterized, Command.Raw -
Method Summary
Modifier and TypeMethodDescriptionGets aPredicatethat backsCommand.canExecute(CommandCause).executor()Gets theCommandExecutorfor this command, if one exists.flags()booleanGets whetherCommand.Builder.terminal(boolean)was explicitly set totrue, such that this command will execute without any arguments, regardless of the command'sparametersorsubcommands.parseArguments(CommandCause cause, ArgumentReader.Mutable arguments) Parses the parameters based on the providedparameters()default CommandResultprocess(CommandCause cause, ArgumentReader.Mutable arguments) Processes the command by parsing the arguments, then executing command based on these arguments.AListof directsubcommandsthat this command contains.Methods inherited from interface org.spongepowered.api.command.Command
canExecute, complete, extendedDescription, help, shortDescription, usage
-
Method Details
-
flags
- Returns:
- A copy of the collection of
Flags.
-
parameters
- Returns:
- A copy of the collection of
Parameters.
-
subcommands
List<Parameter.Subcommand> subcommands()AListof directsubcommandsthat this command contains.A direct subcommand is one that is specified directly after the literal the invokes this command, e.g. on the command
/foo,baris a direct subcommand if it was specified inCommand.Builder.addChild(Parameterized, String...)orCommand.Builder.addChildren(Map)with the aliasbar. This will not contain any subcommands that were registered viaCommand.Builder.addParameter(Parameter)- Returns:
- A copy of the collection of subcommands.
-
isTerminal
boolean isTerminal()Gets whetherCommand.Builder.terminal(boolean)was explicitly set totrue, such that this command will execute without any arguments, regardless of the command'sparametersorsubcommands.- Returns:
- if this
Command.Parameterizedis terminal.
-
executionRequirements
Predicate<CommandCause> executionRequirements()Gets aPredicatethat backsCommand.canExecute(CommandCause).- Returns:
- The predicate.
-
parseArguments
CommandContext parseArguments(CommandCause cause, ArgumentReader.Mutable arguments) throws ArgumentParseException Parses the parameters based on the providedparameters()- Parameters:
cause- TheCauseof this parsearguments- The argumentString- Returns:
- The
CommandContext - Throws:
ArgumentParseException- if a parameter could not be parsed
-
executor
Optional<CommandExecutor> executor()Gets theCommandExecutorfor this command, if one exists.- Returns:
- The
CommandExecutor, if it exists.
-
process
default CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) throws CommandException Processes the command by parsing the arguments, then executing command based on these arguments.By default, this will call
parseArguments(CommandCause, ArgumentReader.Mutable)and pass the resultingCommandContexttoCommandExecutor.execute(CommandContext), if this command has an executor. If it does not, this will throw aCommandException.- Specified by:
processin interfaceCommand- Parameters:
cause- TheCauseof the commandarguments- The raw arguments for this command- Returns:
- The result of a command being processed
- Throws:
CommandException- Thrown on a command error
-