public abstract class PatternMatchingCommandElement extends CommandElement
Modifier | Constructor and Description |
---|---|
protected |
PatternMatchingCommandElement(Text key) |
Modifier and Type | Method and Description |
---|---|
List<String> |
complete(CommandSource src,
CommandArgs args,
CommandContext context)
Fetch completions for command arguments.
|
protected abstract Iterable<String> |
getChoices(CommandSource source)
Get the available choices for this command source.
|
protected abstract Object |
getValue(String choice)
Get the value for a given choice.
|
protected Object |
parseValue(CommandSource source,
CommandArgs args)
Attempt to extract a value for this element from the given arguments.
|
getKey, getUntranslatedKey, getUsage, parse
@Nullable protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException
CommandElement
CommandSource
in any way.parseValue
in class CommandElement
source
- The source to parse forargs
- the argumentsArgumentParseException
- if unable to extract a valuepublic List<String> complete(CommandSource src, CommandArgs args, CommandContext context)
CommandElement
complete
in class CommandElement
src
- The source requesting tab completionsargs
- The arguments currently providedcontext
- The context to store state inprotected abstract Iterable<String> getChoices(CommandSource source)
source
- The source requesting choicesprotected abstract Object getValue(String choice) throws IllegalArgumentException
getChoices(CommandSource)
, this must return a non-null value. Otherwise, an
IllegalArgumentException
may be throw.choice
- The specified choiceIllegalArgumentException
- if the input string is not any return value of getChoices(CommandSource)