Skip to content

Class ArgumentCommandNode

Namespace: Void.Minecraft.Commands.Brigadier.Tree.Nodes
Assembly: Void.Minecraft.dll

Represents a named argument in a Brigadier command tree.

public class ArgumentCommandNode : CommandNode, ICommandNode

Inheritance

objectCommandNodeArgumentCommandNode

Implements

ICommandNode

Inherited Members

CommandNode.IsForks, CommandNode.Requirement, CommandNode.Executor, CommandNode.RedirectTarget, CommandNode.RedirectModifier, CommandNode.Children, CommandNode.Name, CommandNode.UsageText, CommandNode.Examples, CommandNode.SortedKey, CommandNode.AddChild(CommandNode), CommandNode.CanUseAsync(ICommandSource, CancellationToken), CommandNode.FindAmbiguities(AmbiguousConsumer), CommandNode.GetChild(string), CommandNode.RemoveChild(string), CommandNode.GetRelevantNodes(StringReader), CommandNode.CreateBuilder(), CommandNode.IsValidInput(string), CommandNode.ListSuggestionsAsync(CommandContext, SuggestionsBuilder, CancellationToken), CommandNode.Parse(StringReader, CommandContextBuilder), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

An argument node consumes input by delegating parsing and completion behavior to its configured . Parsed values are stored in the active under name, and usage text is rendered as <name>.

Constructors

ArgumentCommandNode(string, IArgumentType, CommandExecutor?, CommandRequirement?, CommandNode?, RedirectModifier?, bool, SuggestionProvider?)

Represents a named argument in a Brigadier command tree.

public ArgumentCommandNode(string name, IArgumentType type, CommandExecutor? executor, CommandRequirement? requirement, CommandNode? redirectTarget, RedirectModifier? redirectModifier, bool isForks, SuggestionProvider? customSuggestions)

Parameters

name string

The argument name used in command contexts, usage text, and child-node lookup.

type IArgumentType

The argument type that parses input, supplies examples, and provides default suggestions.

executor CommandExecutor?

The command executor invoked when parsing completes at this node, or null when the node is not executable.

requirement CommandRequirement?

The predicate that controls whether a source can use this node, or null to allow all sources.

redirectTarget CommandNode?

The node to redirect execution to, or null when this node does not redirect.

redirectModifier RedirectModifier?

The modifier that maps a command context to redirected sources, or null when no redirect modifier is used.

isForks bool

A value indicating whether redirects from this node fork execution to multiple sources.

customSuggestions SuggestionProvider?

The custom suggestion provider for this argument, or null to use type suggestions.

Remarks

An argument node consumes input by delegating parsing and completion behavior to its configured . Parsed values are stored in the active under name, and usage text is rendered as <name>.

Properties

CustomSuggestions

Gets or sets the custom completion provider, or null to delegate to .

public SuggestionProvider? CustomSuggestions { get; set; }

Property Value

SuggestionProvider?

Examples

Gets representative input strings for this argument node.

public override IEnumerable<string> Examples { get; }

Property Value

IEnumerable<string>

Remarks

The sequence is provided by on and is used by command-tree ambiguity detection to test whether sibling nodes can consume the same sample input.

Name

Gets the name used to index this node under its parent.

public override string Name { get; }

Property Value

string

SortedKey

Gets the key used when ordering nodes.

protected override string SortedKey { get; }

Property Value

string

Type

Gets the parser and default completion behavior.

public IArgumentType Type { get; }

Property Value

IArgumentType

UsageText

Gets the fragment displayed in command usage.

public override string UsageText { get; }

Property Value

string

Methods

CreateBuilder()

Creates a builder initialized from this node.

public override IArgumentBuilder<CommandNode> CreateBuilder()

Returns

IArgumentBuilder<CommandNode>

The configured builder.

IsValidInput(string)

Determines whether this node can consume a complete sample input.

public override bool IsValidInput(string input)

Parameters

input string

The sample input.

Returns

bool

Whether the input is valid.

ListSuggestionsAsync(CommandContext, SuggestionsBuilder, CancellationToken)

Lists completions for this node.

public override 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

ValueTask<Suggestions>

The suggestions.

Parse(StringReader, CommandContextBuilder)

Parses this argument from the current position of reader and records the parsed value in contextBuilder.

public override void Parse(StringReader reader, CommandContextBuilder contextBuilder)

Parameters

reader StringReader

The input reader positioned at the beginning of the argument value to parse.

contextBuilder CommandContextBuilder

The command context builder that receives the parsed argument and node range.

Remarks

Parsing is delegated to . On success, the consumed cursor range and returned argument value are stored under , and this node is added to the context path for the same range. The reader cursor remains at the position left by the argument type.

Exceptions

CommandSyntaxException

The configured rejected the input at the reader position.

ToString()

Returns a diagnostic representation containing the name and argument type.

public override string ToString()

Returns

string

The diagnostic representation.