Class CommandContext
Namespace: Void.Minecraft.Commands.Brigadier.Context
Assembly: Void.Minecraft.dll
Contains the parsed nodes, arguments, source, and execution metadata for a command stage.
public record CommandContext : IEquatable<CommandContext>Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
CommandContext(ICommandSource, string, Dictionary<string, IParsedArgument>, CommandExecutor?, CommandNode, List<ParsedCommandNode>, StringRange, CommandContext?, RedirectModifier?, bool)
Contains the parsed nodes, arguments, source, and execution metadata for a command stage.
public CommandContext(ICommandSource Source, string Input, Dictionary<string, IParsedArgument> Arguments, CommandExecutor? Executor, CommandNode RootNode, List<ParsedCommandNode> Nodes, StringRange Range, CommandContext? Child, RedirectModifier? RedirectModifier, bool Forks)Parameters
Source ICommandSource
The command source for this context.
Input string
The complete command input.
Arguments Dictionary<string, IParsedArgument>
Parsed arguments keyed by node name.
Executor CommandExecutor?
The executor associated with the final parsed node, if any.
RootNode CommandNode
The tree root used for parsing.
Nodes List<ParsedCommandNode>
The parsed command-node sequence.
Range StringRange
The input range covered by this context.
Child CommandContext?
The redirected child context, if any.
RedirectModifier RedirectModifier?
The source modifier applied before entering the child.
Forks bool
Whether this redirect forks execution across sources.
Properties
Arguments
Parsed arguments keyed by node name.
public Dictionary<string, IParsedArgument> Arguments { get; init; }Property Value
Dictionary<string, IParsedArgument>
Child
The redirected child context, if any.
public CommandContext? Child { get; init; }Property Value
Executor
The executor associated with the final parsed node, if any.
public CommandExecutor? Executor { get; init; }Property Value
Forks
Whether this redirect forks execution across sources.
public bool Forks { get; init; }Property Value
HasNodes
Gets whether at least one command node was parsed.
public bool HasNodes { get; }Property Value
Input
The complete command input.
public string Input { get; init; }Property Value
Nodes
The parsed command-node sequence.
public List<ParsedCommandNode> Nodes { get; init; }Property Value
Range
The input range covered by this context.
public StringRange Range { get; init; }Property Value
RedirectModifier
The source modifier applied before entering the child.
public RedirectModifier? RedirectModifier { get; init; }Property Value
RootNode
The tree root used for parsing.
public CommandNode RootNode { get; init; }Property Value
Source
The command source for this context.
public ICommandSource Source { get; init; }Property Value
Methods
CopyFor(ICommandSource)
Returns this context for an equal source, or a shallow copy using another source.
public CommandContext CopyFor(ICommandSource source)Parameters
source ICommandSource
The source to associate.
Returns
This instance or the source-adjusted copy.
GetArgument<TType>(string)
Gets and converts a parsed argument value by name.
public TType GetArgument<TType>(string name)Parameters
name string
The argument name.
Returns
TType
The converted argument value.
Type Parameters
TType
The requested result type.
Exceptions
The argument is absent or has an incompatible result type.
GetLastChild()
Traverses redirected children to the final context.
public CommandContext GetLastChild()Returns
The last context in the child chain.
TryGetArgument<TType>(string, out TType)
Attempts to get and convert a parsed argument value by name.
public bool TryGetArgument<TType>(string name, out TType type)Parameters
name string
The argument name.
type TType
The converted value when found.
Returns
false only when the name is absent; otherwise true.
Type Parameters
TType
The requested result type.
Exceptions
The argument exists but its result has an incompatible type.