Interface Command.Parameterized
-
- All Superinterfaces:
Command
- Enclosing interface:
- Command
public static interface Command.Parameterized extends Command
ACommandthat 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Predicate<CommandCause>executionRequirements()Gets aPredicatethat backsCommand.canExecute(CommandCause).Optional<CommandExecutor>executor()Gets theCommandExecutorfor this command, if one exists.List<Flag>flags()booleanisTerminal()Gets whetherCommand.Builder.terminal(boolean)was explicitly set totrue, such that this command will execute without any arguments, regardless of the command'sparametersorsubcommands.List<Parameter>parameters()CommandContextparseArguments(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.List<Parameter.Subcommand>subcommands()AListof directsubcommandsthat this command contains.-
Methods inherited from interface org.spongepowered.api.command.Command
canExecute, complete, extendedDescription, help, shortDescription, usage
-
-
-
-
Method Detail
-
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
-
-