CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
|
A builder for CommandContext
objects.
More...
Public Member Functions | |
CommandContextBuilder (final CommandDispatcher< S > dispatcher, final S source, final CommandNode< S > rootNode, final int start) | |
Creates a new CommandContextBuilder. More... | |
CommandContextBuilder< S > | withSource (final S source) |
Sets the source for this command. More... | |
S | getSource () |
The command source for the built command context. More... | |
CommandNode< S > | getRootNode () |
Returns the root node in the command tree. More... | |
CommandContextBuilder< S > | withArgument (final String name, final ParsedArgument< S, ?> argument) |
Stores an argument in this command, that can later be retrieved. More... | |
Map< String, ParsedArgument< S, ?> > | getArguments () |
Returns all stored arguments. More... | |
CommandContextBuilder< S > | withCommand (final Command< S > command) |
Sets the command to execute, i.e. More... | |
CommandContextBuilder< S > | withNode (final CommandNode< S > node, final StringRange range) |
Adds the given command node alongside its parsed range to this context. More... | |
CommandContextBuilder< S > | copy () |
Creates a shallow copy of this builder. More... | |
CommandContextBuilder< S > | withChild (final CommandContextBuilder< S > child) |
Sets a child context, which is the context for a child command node. More... | |
CommandContextBuilder< S > | getChild () |
Returns the child context, i.e. More... | |
CommandContextBuilder< S > | getLastChild () |
Returns the last child command context in the chain, i.e. More... | |
Command< S > | getCommand () |
Returns the command to execute. More... | |
List< ParsedCommandNode< S > > | getNodes () |
Returns a list with all nodes. More... | |
CommandContext< S > | build (final String input) |
Builds the command context. More... | |
CommandDispatcher< S > | getDispatcher () |
Returns the CommandDispatcher set in the constructor. More... | |
StringRange | getRange () |
Returns the range this context spans in the input. More... | |
SuggestionContext< S > | findSuggestionContext (final int cursor) |
Finds the SuggestionContext given a cursor value. More... | |
A builder for CommandContext
objects.
<S> | the type of the command source |
com.mojang.brigadier.context.CommandContextBuilder< S >.CommandContextBuilder | ( | final CommandDispatcher< S > | dispatcher, |
final S | source, | ||
final CommandNode< S > | rootNode, | ||
final int | start | ||
) |
Creates a new CommandContextBuilder.
dispatcher | the CommandDispatcher TODO: Why does this exist here? |
source | the command source |
rootNode | the root node of the command tree |
start | the start in the input that this context spans |
CommandContext< S > com.mojang.brigadier.context.CommandContextBuilder< S >.build | ( | final String | input | ) |
Builds the command context.
input | the input string |
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.copy | ( | ) |
Creates a shallow copy of this builder.
SuggestionContext< S > com.mojang.brigadier.context.CommandContextBuilder< S >.findSuggestionContext | ( | final int | cursor | ) |
Finds the SuggestionContext
given a cursor value.
This method attempts to find the correct command node responsible at the given cursor position.
cursor | the cursor position to find a suggestion context for |
SuggestionContext
for the given cursor value IllegalStateException | if the cursor position is smaller than the getRange() or not within the bounds of any registered node |
Map< String, ParsedArgument< S, ?> > com.mojang.brigadier.context.CommandContextBuilder< S >.getArguments | ( | ) |
Returns all stored arguments.
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.getChild | ( | ) |
Returns the child context, i.e.
the context for a child command node.
Command< S > com.mojang.brigadier.context.CommandContextBuilder< S >.getCommand | ( | ) |
Returns the command to execute.
CommandDispatcher< S > com.mojang.brigadier.context.CommandContextBuilder< S >.getDispatcher | ( | ) |
Returns the CommandDispatcher
set in the constructor.
TODO: WHY?
CommandDispatcher
set in the constructor CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.getLastChild | ( | ) |
Returns the last child command context in the chain, i.e.
the lowest child you can reach from this context.
As each CommandContextBuilder 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.CommandContextBuilder< S >.getNodes | ( | ) |
StringRange com.mojang.brigadier.context.CommandContextBuilder< S >.getRange | ( | ) |
Returns the range this context spans in the input.
CommandNode< S > com.mojang.brigadier.context.CommandContextBuilder< S >.getRootNode | ( | ) |
Returns the root node in the command tree.
S com.mojang.brigadier.context.CommandContextBuilder< S >.getSource | ( | ) |
The command source for the built command context.
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.withArgument | ( | final String | name, |
final ParsedArgument< S, ?> | argument | ||
) |
Stores an argument in this command, that can later be retrieved.
name | the name of the argument |
argument | the argument to store |
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.withChild | ( | final CommandContextBuilder< S > | child | ) |
Sets a child context, which is the context for a child command node.
child | the child context |
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.withCommand | ( | final Command< S > | command | ) |
Sets the command to execute, i.e.
the one that was matched by this context.
command | the Command that should be executed |
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.withNode | ( | final CommandNode< S > | node, |
final StringRange | range | ||
) |
Adds the given command node alongside its parsed range to this context.
You should probably not call this method in your code, as duplicate invocations could put the builder into an invalid state.
node | the command node to add |
range | the range the node spans in the input |
CommandContextBuilder< S > com.mojang.brigadier.context.CommandContextBuilder< S >.withSource | ( | final S | source | ) |
Sets the source for this command.
source | thr command source |