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 aPredicate
that backsCommand.canExecute(CommandCause)
.executor()
Gets theCommandExecutor
for this command, if one exists.flags()
boolean
Gets whetherCommand.Builder.terminal(boolean)
was explicitly set totrue
, such that this command will execute without any arguments, regardless of the command'sparameters
orsubcommands
.parseArguments
(CommandCause cause, ArgumentReader.Mutable arguments) Parses the parameters based on the providedparameters()
default CommandResult
process
(CommandCause cause, ArgumentReader.Mutable arguments) Processes the command by parsing the arguments, then executing command based on these arguments.AList
of directsubcommands
that 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
Flag
s.
-
parameters
- Returns:
- A copy of the collection of
Parameter
s.
-
subcommands
List<Parameter.Subcommand> subcommands()AList
of directsubcommands
that 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
,bar
is 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'sparameters
orsubcommands
.- Returns:
- if this
Command.Parameterized
is terminal.
-
executionRequirements
Predicate<CommandCause> executionRequirements()Gets aPredicate
that 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
- TheCause
of this parsearguments
- The argumentString
- Returns:
- The
CommandContext
- Throws:
ArgumentParseException
- if a parameter could not be parsed
-
executor
Optional<CommandExecutor> executor()Gets theCommandExecutor
for 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 resultingCommandContext
toCommandExecutor.execute(CommandContext)
, if this command has an executor. If it does not, this will throw aCommandException
.- Specified by:
process
in interfaceCommand
- Parameters:
cause
- TheCause
of the commandarguments
- The raw arguments for this command- Returns:
- The result of a command being processed
- Throws:
CommandException
- Thrown on a command error
-