Class CommandContextBuilder
Namespace: Void.Minecraft.Commands.Brigadier.Context
Assembly: Void.Minecraft.dll
Accumulates parse results for one stage of a potentially redirected command.
public class CommandContextBuilderInheritance
object ← CommandContextBuilder
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
CommandContextBuilder(CommandDispatcher, ICommandSource, CommandNode, int)
Creates an empty context builder at a parse position.
public CommandContextBuilder(CommandDispatcher dispatcher, ICommandSource source, CommandNode rootNode, int start)Parameters
dispatcher CommandDispatcher
The dispatcher owning the tree.
source ICommandSource
The command source.
rootNode CommandNode
The parsing root.
start int
The initial cursor.
Properties
Arguments
Gets the mutable parsed-argument map.
public Dictionary<string, IParsedArgument> Arguments { get; }Property Value
Dictionary<string, IParsedArgument>
Child
Gets or sets the redirected child context builder.
public CommandContextBuilder? Child { get; set; }Property Value
Command
Gets or sets the executor selected by parsing.
public CommandExecutor? Command { get; set; }Property Value
Dispatcher
Gets or sets the dispatcher that owns the parsed tree.
public CommandDispatcher Dispatcher { get; set; }Property Value
IsFork
Gets or sets whether the redirect forks across sources.
public bool IsFork { get; set; }Property Value
Nodes
Gets the mutable parsed-node sequence.
public List<ParsedCommandNode> Nodes { get; }Property Value
Range
Gets or sets the aggregate input range covered by parsed nodes.
public StringRange Range { get; set; }Property Value
RedirectModifier
Gets or sets the redirect source modifier.
public RedirectModifier? RedirectModifier { get; set; }Property Value
RootNode
Gets or sets the parsing root node.
public CommandNode RootNode { get; set; }Property Value
Source
Gets or sets the command source.
public ICommandSource Source { get; set; }Property Value
Start
Gets or sets the initial parse cursor.
public int Start { get; set; }Property Value
Methods
Build(string)
Creates an immutable command context and recursively builds its child.
public CommandContext Build(string input)Parameters
input string
The complete command input.
Returns
The built context.
Exceptions
BuildSuggestions(int)
Locates the command-tree position at which suggestions should be requested.
public SuggestionContext BuildSuggestions(int cursor)Parameters
cursor int
The completion cursor.
Returns
The parent node and token start.
Exceptions
No node precedes the cursor within this context or its children.
Copy()
Creates a shallow copy with new node and argument collections.
public CommandContextBuilder Copy()Returns
The copied builder. Its child, source, nodes, and argument values remain shared objects.
GetLastChild()
Traverses redirected children to the final builder.
public CommandContextBuilder GetLastChild()Returns
The last builder in the child chain.
WithArgument(string, ParsedArgument)
Records a parsed argument by name for the command context being built.
public CommandContextBuilder WithArgument(string name, ParsedArgument argument)Parameters
name string
The argument name from the command tree.
argument ParsedArgument
The parsed argument range and value to associate with name.
Returns
The current
Remarks
If an argument with the same name was already recorded, it is replaced.
Exceptions
name is null.
WithChild(CommandContextBuilder)
Sets the redirected child stage.
public CommandContextBuilder WithChild(CommandContextBuilder child)Parameters
child CommandContextBuilder
The child builder.
Returns
This builder.
WithExecutor(CommandExecutor?)
Associates an executor with this stage.
public CommandContextBuilder WithExecutor(CommandExecutor? command)Parameters
command CommandExecutor?
The executor, or null to clear it.
Returns
This builder.
WithNode(CommandNode, StringRange)
Appends a parsed node and adopts its redirect metadata.
public CommandContextBuilder WithNode(CommandNode node, StringRange range)Parameters
node CommandNode
The parsed node.
range StringRange
The consumed range.
Returns
This builder.
WithSource(ICommandSource)
Replaces the command source.
public CommandContextBuilder WithSource(ICommandSource source)Parameters
source ICommandSource
The new source.
Returns
This builder.