Interface ValueParameter.Simple<T>
- Type Parameters:
T
- The type of object that is returned from theValueParser
upon successful parsing.
- All Superinterfaces:
DefaultedRegistryValue
,ValueCompleter
,ValueParameter<T>
,ValueParser<T>
,ValueUsage
- All Known Subinterfaces:
ResourceKeyedValueParameter<T>
- Enclosing interface:
- ValueParameter<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.command.parameter.managed.ValueParameter
ValueParameter.Simple<T>
-
Method Summary
Modifier and TypeMethodDescriptioncomplete
(CommandCause context, String currentInput) Gets valid completions for this element, given the suppliedCommandCause
and current input for this element.default List<CommandCompletion>
complete
(CommandContext context, String currentInput) This should not be overridden by implementations of this class.parseValue
(CommandCause commandCause, ArgumentReader.Mutable reader) Gets the value for this parameter.parseValue
(Parameter.Key<? super T> parameterKey, ArgumentReader.Mutable reader, CommandContext.Builder context) This should not be overridden by implementations of this class.Methods inherited from interface org.spongepowered.api.registry.DefaultedRegistryValue
asDefaultedReference, findKey, key
Methods inherited from interface org.spongepowered.api.command.parameter.managed.ValueParameter
usage
Methods inherited from interface org.spongepowered.api.command.parameter.managed.ValueParser
clientCompletionType
-
Method Details
-
parseValue
Optional<? extends T> parseValue(CommandCause commandCause, ArgumentReader.Mutable reader) throws ArgumentParseException Gets the value for this parameter.This should have no side effects on anything except on the state of the
ArgumentReader
.This element may return nothing in the form of an empty optional. This indicates that a parse succeeded, but no meaningful value was returned.
- Parameters:
commandCause
- Thecause
of this parsereader
- TheArgumentReader
that contains the unparsed arguments- Returns:
- Returns the value(s)
- Throws:
ArgumentParseException
- if a parameter could not be parsed
-
parseValue
default Optional<? extends T> parseValue(Parameter.Key<? super T> parameterKey, ArgumentReader.Mutable reader, CommandContext.Builder context) throws ArgumentParseException This should not be overridden by implementations of this class. If you wish to do so, implementValueParameter
instead. Gets the value for the parameter. This may return more than one value by adding additional values to the suppliedCommandContext.Builder
.This should have no side effects on anything except on the state of the
ArgumentReader
and, in rare cases, theCommandContext.Builder
.This element may return nothing in the form of an empty optional. This indicates that a parse succeeded, but no meaningful value was returned, for example, the argument must be passed but it's not necessary for the associated
CommandExecutor
to know what the result of the parse was. TheCommandContext.Builder
may be updated in this case.While the
CommandContext.Builder
is provided, in general, you do not need to add the parsed value to it yourself, instead preferring to return your parsed value. It is permissible, however, to add additional information to the context should it be required.The
Cause
of this parse is provided in theCommandContext.Builder
.- Specified by:
parseValue
in interfaceValueParser<T>
- Parameters:
parameterKey
- TheParameter.Key
of the parameter being parsedreader
- TheArgumentReader
that contains the unparsed argumentscontext
- TheCommandContext
containing the state about this command- Returns:
- Returns the value(s)
- Throws:
ArgumentParseException
- if a parameter could not be parsed
-
complete
Gets valid completions for this element, given the suppliedCommandCause
and current input for this element.- Parameters:
context
- TheCommandCause
that contains the parsed argumentscurrentInput
- The current input for this argument- Returns:
- The list of values
-
complete
This should not be overridden by implementations of this class. If you wish to do so, implementValueParameter
instead. Gets valid completions for this element, given the suppliedCommandContext
and current input for this element.- Specified by:
complete
in interfaceValueCompleter
- Parameters:
context
- TheCommandContext
that contains the parsed argumentscurrentInput
- The current input for this argument- Returns:
- The list of values
-