public abstract class CommandElement extends Object
Modifier | Constructor and Description |
---|---|
protected |
CommandElement(Text key) |
Modifier and Type | Method and Description |
---|---|
abstract List<String> |
complete(CommandSource src,
CommandArgs args,
CommandContext context)
Fetch completions for command arguments.
|
Text |
getKey()
Return the key to be used for this object.
|
String |
getUntranslatedKey()
Return the plain key, to be used when looking up this command element in
a
CommandContext . |
Text |
getUsage(CommandSource src)
Return a usage message for this specific argument.
|
void |
parse(CommandSource source,
CommandArgs args,
CommandContext context)
Attempt to extract a value for this element from the given arguments and
put it in the given context.
|
protected abstract Object |
parseValue(CommandSource source,
CommandArgs args)
Attempt to extract a value for this element from the given arguments.
|
@Nullable public Text getKey()
@Nullable public String getUntranslatedKey()
CommandContext
. If the key is a TranslatableText
, this
is the translation's id. Otherwise, this is the result of
Text.toPlain()
.public void parse(CommandSource source, CommandArgs args, CommandContext context) throws ArgumentParseException
parseValue(CommandSource, CommandArgs)
for getting the values.
This method is expected to have no side-effects for the source, meaning
that executing it will not change the state of the CommandSource
in any way.source
- The source to parse forargs
- The args to extract fromcontext
- The context to supply toArgumentParseException
- if unable to extract a value@Nullable protected abstract Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException
CommandSource
in any way.source
- The source to parse forargs
- the argumentsArgumentParseException
- if unable to extract a valuepublic abstract List<String> complete(CommandSource src, CommandArgs args, CommandContext context)
src
- The source requesting tab completionsargs
- The arguments currently providedcontext
- The context to store state inpublic Text getUsage(CommandSource src)
src
- The source requesting usage