Class CommandNode
Namespace: Void.Minecraft.Commands.Brigadier.Tree
Assembly: Void.Minecraft.dll
Provides shared storage, traversal, access checks, and ambiguity analysis for command-tree nodes.
public abstract class CommandNode : ICommandNodeInheritance
Derived
ArgumentCommandNode, LiteralCommandNode, RootCommandNode
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
CommandNode(CommandExecutor?, CommandRequirement?, CommandNode?, RedirectModifier?, bool)
Provides shared storage, traversal, access checks, and ambiguity analysis for command-tree nodes.
protected CommandNode(CommandExecutor? executor = null, CommandRequirement? requirement = null, CommandNode? redirectTarget = null, RedirectModifier? redirectModifier = null, bool isForks = false)Parameters
executor CommandExecutor?
The executor selected when parsing ends at this node.
requirement CommandRequirement?
The source access requirement.
redirectTarget CommandNode?
The redirect target.
redirectModifier RedirectModifier?
The redirected-source modifier.
isForks bool
Whether redirection forks execution.
Properties
Children
Gets the child nodes in dictionary enumeration order.
public IEnumerable<CommandNode> Children { get; }Property Value
Examples
Gets representative inputs used for ambiguity analysis.
public abstract IEnumerable<string> Examples { get; }Property Value
Executor
Gets or sets the command executor.
public CommandExecutor? Executor { get; set; }Property Value
IsForks
Gets or sets whether redirection forks execution.
public bool IsForks { get; set; }Property Value
Name
Gets the name used to index this node under its parent.
public abstract string Name { get; }Property Value
RedirectModifier
Gets or sets the redirected-source modifier.
public RedirectModifier? RedirectModifier { get; set; }Property Value
RedirectTarget
Gets or sets the redirect target.
public CommandNode? RedirectTarget { get; set; }Property Value
Requirement
Gets or sets the source access requirement.
public CommandRequirement? Requirement { get; set; }Property Value
SortedKey
Gets the key used when ordering nodes.
protected abstract string SortedKey { get; }Property Value
UsageText
Gets the fragment displayed in command usage.
public abstract string UsageText { get; }Property Value
Methods
AddChild(CommandNode)
Adds or merges a child by name.
public void AddChild(CommandNode node)Parameters
node CommandNode
The child to add.
Remarks
When a same-name child exists, a non-null executor and all grandchildren are merged into that existing node; other metadata is retained.
Exceptions
node is a root node.
CanUseAsync(ICommandSource, CancellationToken)
Evaluates this node’s access requirement.
public ValueTask<bool> CanUseAsync(ICommandSource source, CancellationToken cancellationToken)Parameters
source ICommandSource
The command source.
cancellationToken CancellationToken
A token that may cancel the requirement.
Returns
true when no requirement exists or it permits the source.
CreateBuilder()
Creates a builder initialized from this node.
public abstract IArgumentBuilder<CommandNode> CreateBuilder()Returns
The configured builder.
FindAmbiguities(AmbiguousConsumer)
Recursively reports sibling pairs whose examples are accepted by one another.
public void FindAmbiguities(AmbiguousConsumer consumer)Parameters
consumer AmbiguousConsumer
The callback receiving the parent, child pair, and overlapping examples.
GetChild(string)
Gets a child by exact name.
public CommandNode GetChild(string name)Parameters
name string
The child name.
Returns
The child node.
Exceptions
No child has that name.
GetRelevantNodes(StringReader)
Selects a same-text literal when present, otherwise returns argument children.
public IEnumerable<CommandNode> GetRelevantNodes(StringReader reader)Parameters
reader StringReader
The reader used to inspect the next space-delimited token; its cursor is restored.
Returns
The literal singleton or all argument nodes.
IsValidInput(string)
Determines whether this node can consume a complete sample input.
public abstract bool IsValidInput(string input)Parameters
input string
The sample input.
Returns
Whether the input is valid.
ListSuggestionsAsync(CommandContext, SuggestionsBuilder, CancellationToken)
Lists completions for this node.
public abstract ValueTask<Suggestions> ListSuggestionsAsync(CommandContext context, SuggestionsBuilder builder, CancellationToken cancellationToken)Parameters
context CommandContext
The parsed context.
builder SuggestionsBuilder
The suggestion builder.
cancellationToken CancellationToken
A cancellation token.
Returns
The suggestions.
Parse(StringReader, CommandContextBuilder)
Parses this node and records its result in a context builder.
public abstract void Parse(StringReader reader, CommandContextBuilder context)Parameters
reader StringReader
The input reader.
context CommandContextBuilder
The parse context builder.
RemoveChild(string)
Removes a child from the general child map.
public bool RemoveChild(string name)Parameters
name string
The child name.
Returns
Whether the general child map contained the name.
Remarks
The specialized literal and argument lookup maps are not updated.