CommandNode
Namespace Mc.Scripting.Commands · Kind class (sealed)
public sealed class CommandNodeA node of a command tree under construction: a literal word or a typed argument, with children, an executor, requirements and suggestions. Build trees with Command.Literal / Command.Argument and register them with CommandRegistry.Register.
Properties
Section titled “Properties”| Member | Description |
|---|---|
bool IsLiteral { get; } |
Whether this is a literal word. |
string Name { get; } |
The literal word or the argument name. |
ArgType? Type { get; } |
The argument type, null for a literal. |
IsLiteral
Section titled “IsLiteral”public bool IsLiteral { get; }Whether this is a literal word.
public string Name { get; }The literal word or the argument name.
public ArgType? Type { get; }The argument type, null for a literal.
Methods
Section titled “Methods”| Member | Description |
|---|---|
CommandNode Executes(CommandExecutor executor) |
Runs executor when the command line ends at this node. |
CommandNode Executes(Action<CommandContext> action) |
Runs action when the command line ends at this node; the result is CommandContext.Result (default 1). |
CommandNode OpLevel(int level) |
Requires a vanilla operator level (0-4) for this node. |
CommandNode Permission(string node) |
Requires a permission node (see Mc.Scripting.Permissions) to see and use this node. |
CommandNode Requires(Func<CommandSource, bool> requirement) |
Requires an arbitrary condition of the command source. |
CommandNode Suggests(SuggestionProvider provider) |
Provides tab-completion suggestions for this argument (server-side, on the tick thread). |
CommandNode Suggests(Func<CommandContext, IEnumerable<string>> provider) |
Provides suggestions from a list computed on the tick thread. |
CommandNode SuggestsAsync(AsyncSuggestionProvider provider) |
Provides suggestions asynchronously (the client waits until the task completes). |
CommandNode Then(CommandNode child) |
Adds a child node. |
Executes
Section titled “Executes”public CommandNode Executes(CommandExecutor executor)Runs executor when the command line ends at this node.
Parameters
| Name | Type | Description |
|---|---|---|
executor |
CommandExecutor |
Returns the command result (1 = success). |
Returns CommandNode: This node.
Executes
Section titled “Executes”public CommandNode Executes(Action<CommandContext> action)Runs action when the command line ends at this node; the result is CommandContext.Result (default 1).
Parameters
| Name | Type | Description |
|---|---|---|
action |
Action<CommandContext> |
The command body. |
Returns CommandNode: This node.
OpLevel
Section titled “OpLevel”public CommandNode OpLevel(int level)Requires a vanilla operator level (0-4) for this node.
Parameters
| Name | Type | Description |
|---|---|---|
level |
int |
The minimum permission level. |
Returns CommandNode: This node.
Permission
Section titled “Permission”public CommandNode Permission(string node)Requires a permission node (see Mc.Scripting.Permissions) to see and use this node. Players without it do not get the node in their client’s tree. The console always passes.
Parameters
| Name | Type | Description |
|---|---|---|
node |
string |
The permission node, e.g. “homes.use”. |
Returns CommandNode: This node.
Requires
Section titled “Requires”public CommandNode Requires(Func<CommandSource, bool> requirement)Requires an arbitrary condition of the command source. A node with a condition is encoded per player in the client’s command tree.
Parameters
| Name | Type | Description |
|---|---|---|
requirement |
Func<CommandSource, bool> |
Returns true when the source may use the node. |
Returns CommandNode: This node.
Suggests
Section titled “Suggests”public CommandNode Suggests(SuggestionProvider provider)Provides tab-completion suggestions for this argument (server-side, on the tick thread).
Parameters
| Name | Type | Description |
|---|---|---|
provider |
SuggestionProvider |
Fills the suggestions. |
Returns CommandNode: This node.
Suggests
Section titled “Suggests”public CommandNode Suggests(Func<CommandContext, IEnumerable<string>> provider)Provides suggestions from a list computed on the tick thread.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
Func<CommandContext, IEnumerable<string>> |
Returns the candidate words; the engine filters them by what was typed. |
Returns CommandNode: This node.
SuggestsAsync
Section titled “SuggestsAsync”public CommandNode SuggestsAsync(AsyncSuggestionProvider provider)Provides suggestions asynchronously (the client waits until the task completes).
Parameters
| Name | Type | Description |
|---|---|---|
provider |
AsyncSuggestionProvider |
Returns the candidates; runs off the tick thread after the call returns. |
Returns CommandNode: This node.
public CommandNode Then(CommandNode child)Adds a child node.
Parameters
| Name | Type | Description |
|---|---|---|
child |
CommandNode |
The next literal or argument. |
Returns CommandNode: This node (fluent).
See also
Section titled “See also”ArgType · AsyncSuggestionProvider · CommandContext · CommandExecutor · CommandSource · Permission · SuggestionProvider