- All Known Subinterfaces:
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
parseValueOptional<? extends T> parseValue
(Parameter.Key<? super T> parameterKey, ArgumentReader.Mutable reader, CommandContext.Builder context) throws ArgumentParseExceptionGets the value for the parameter. This may return more than one value by adding additional values to the supplied
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
CommandExecutorto know what the result of the parse was. The
CommandContext.Buildermay be updated in this case.
CommandContext.Builderis 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.
Parameter.Keyof the parameter being parsed
ArgumentReaderthat contains the unparsed arguments
CommandContextcontaining the state about this command
- Returns the value(s)
ArgumentParseException- if a parameter could not be parsed
clientCompletionTypeProvides a hint to the client completion engine what sort of input(s) the client should expect.
Multiple elements can be placed here for multi part parsers - that is, parsers that call parse methods on the
ArgumentReader.Mutablemore than once. However, it is recommended that you consider splitting your parsers up to consume one element at any time, any completions you provide may not be provided to the client if you do so.
Returning an empty list does not infer that the element will not be displayed, rather, an empty list infers that the command system will decide. Custom parsers will default to a single
ClientCompletionTypes.STRING. Be aware, providing a non-string type here may cause your completions to be ignored.
Remember that anything supplied here is a hint. It is possible that this hint will be ignored in some scenarios, particularly if this parser is one of many supplied to
ClientCompletionTypes to use on the client.