CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
|
A general container class storing information needed to invoke a command. More...
Public Member Functions | |
CommandContext (final S source, final String input, final Map< String, ParsedArgument< S, ?> > arguments, final Command< S > command, final CommandNode< S > rootNode, final List< ParsedCommandNode< S > > nodes, final StringRange range, final CommandContext< S > child, final RedirectModifier< S > modifier, boolean forks) | |
Creates a new CommandContext. More... | |
CommandContext< S > | copyFor (final S source) |
Creates a copy of this CommandContext with a different command source but otherwise identical. More... | |
CommandContext< S > | getChild () |
Returns the child context, if it is present. More... | |
CommandContext< S > | getLastChild () |
Returns the last child command context in the chain, i.e. More... | |
Command< S > | getCommand () |
Returns the command that should be executed. More... | |
S | getSource () |
The command source to invoke the command for. More... | |
boolean | equals (final Object o) |
int | hashCode () |
RedirectModifier< S > | getRedirectModifier () |
Returns the RedirectModifier to apply when invoking the command. More... | |
StringRange | getRange () |
Returns the range this context takes up in the input string. More... | |
String | getInput () |
Returns the full input, of which this command context is a part. More... | |
CommandNode< S > | getRootNode () |
Returns the root command node in the command tree. More... | |
List< ParsedCommandNode< S > > | getNodes () |
Returns all nodes associated with this context. More... | |
boolean | hasNodes () |
Returns true if this context has any CommandNode associated with it. More... | |
boolean | isForked () |
Returns true if this command is forked. More... | |
A general container class storing information needed to invoke a command.
This consists of e.g. the command source to invoke it for, the command to invoke, child contexts (for subcommands) or arguments parsed by ArgumentType
s.
This class is immutable. Use copyFor(Object)
to create copies with a different command source.
<S> | the type of the command source |
com.mojang.brigadier.context.CommandContext< S >.CommandContext | ( | final S | source, |
final String | input, | ||
final Map< String, ParsedArgument< S, ?> > | arguments, | ||
final Command< S > | command, | ||
final CommandNode< S > | rootNode, | ||
final List< ParsedCommandNode< S > > | nodes, | ||
final StringRange | range, | ||
final CommandContext< S > | child, | ||
final RedirectModifier< S > | modifier, | ||
boolean | forks | ||
) |
Creates a new CommandContext.
source | the command source to invoke the command for |
input | the full input |
arguments | the parsed arguments |
command | the command to invoke |
rootNode | the root node of the command tree |
nodes | all nodes associated with this context |
range | the string range indicating what part in the input this context covers |
child | the child context, or null if none |
modifier | the RedirectModifier to apply when invoking the command |
forks | whether this command forks. See CommandDispatcher#execute(ParseResults) for an explanation |
CommandContext< S > com.mojang.brigadier.context.CommandContext< S >.copyFor | ( | final S | source | ) |
Creates a copy of this CommandContext
with a different command source but otherwise identical.
source | the command source to copy it for |
CommandContext
that is identical to this one, except for the command source CommandContext< S > com.mojang.brigadier.context.CommandContext< S >.getChild | ( | ) |
Returns the child context, if it is present.
Command< S > com.mojang.brigadier.context.CommandContext< S >.getCommand | ( | ) |
Returns the command that should be executed.
String com.mojang.brigadier.context.CommandContext< S >.getInput | ( | ) |
Returns the full input, of which this command context is a part.
CommandContext< S > com.mojang.brigadier.context.CommandContext< S >.getLastChild | ( | ) |
Returns the last child command context in the chain, i.e.
the lowest child you can reach from this context.
As each CommandContext can have a child, you can have a child of a child. This method returns the lowest possible child you can reach, i.e. the last command context that has no children. This can be this command context instance, if it has no child.
List< ParsedCommandNode< S > > com.mojang.brigadier.context.CommandContext< S >.getNodes | ( | ) |
Returns all nodes associated with this context.
That is the node that getCommand()
comes from any anything else that nodes pushes onto it in its CommandNode#parse
method.
TODO: Why is this a List?
StringRange com.mojang.brigadier.context.CommandContext< S >.getRange | ( | ) |
Returns the range this context takes up in the input string.
RedirectModifier< S > com.mojang.brigadier.context.CommandContext< S >.getRedirectModifier | ( | ) |
Returns the RedirectModifier
to apply when invoking the command.
RedirectModifier
to apply when invoking the command or null if none is set CommandNode< S > com.mojang.brigadier.context.CommandContext< S >.getRootNode | ( | ) |
Returns the root command node in the command tree.
S com.mojang.brigadier.context.CommandContext< S >.getSource | ( | ) |
The command source to invoke the command for.
boolean com.mojang.brigadier.context.CommandContext< S >.hasNodes | ( | ) |
Returns true if this context has any CommandNode
associated with it.
CommandNode
associated with it boolean com.mojang.brigadier.context.CommandContext< S >.isForked | ( | ) |
Returns true if this command is forked.
See CommandDispatcher#execute(ParseResults)
for a detailed explanation.