API reference / @jsprismarine/brigadier / CommandNode
Abstract Class: CommandNode<S>
Defined in: brigadier/src/tree/CommandNode.ts:15
One node of a command tree: a literal, an argument or the root, with its children.
Extended by
Type Parameters
S
S
Constructors
Constructor
new CommandNode<
S>(command,requirement,redirect,modifier,forks):CommandNode<S>
Defined in: brigadier/src/tree/CommandNode.ts:35
Parameters
command
Command<S> | null
requirement
Predicate<S> | null
redirect
CommandNode<S> | null
modifier
RedirectModifier<S> | null
forks
boolean
Returns
CommandNode<S>
Methods
addChild()
addChild(
node):void
Defined in: brigadier/src/tree/CommandNode.ts:85
Adds a child, merging it into an existing child of the same name. Throws for a root node.
Parameters
node
CommandNode<S>
Returns
void
canUse()
canUse(
source):boolean
Defined in: brigadier/src/tree/CommandNode.ts:80
Returns whether source passes the node's requirement.
Parameters
source
S
Returns
boolean
compareTo()
compareTo(
o):number
Defined in: brigadier/src/tree/CommandNode.ts:201
Orders literals before arguments, and nodes of one kind by their sorted keys.
Parameters
o
CommandNode<S>
Returns
number
createBuilder()
abstractcreateBuilder():ArgumentBuilder<S,any>
Defined in: brigadier/src/tree/CommandNode.ts:174
Returns a builder that builds a copy of the node.
Returns
ArgumentBuilder<S, any>
equals()
equals(
o):boolean
Defined in: brigadier/src/tree/CommandNode.ts:141
Returns whether o is a node with equal children and an equal command.
Parameters
o
object
Returns
boolean
findAmbiguities()
findAmbiguities(
consumer,context):void
Defined in: brigadier/src/tree/CommandNode.ts:113
Reports each pair of sibling nodes, at any depth, that accept the same example input.
Parameters
consumer
context
any
Returns
void
getChild()
getChild(
name):CommandNode<S> |undefined
Defined in: brigadier/src/tree/CommandNode.ts:65
Returns the child with the given name, if there is one.
Parameters
name
string
Returns
CommandNode<S> | undefined
getChildren()
getChildren():
MapIterator<CommandNode<S>>
Defined in: brigadier/src/tree/CommandNode.ts:55
Returns the child nodes, literals before arguments.
Returns
MapIterator<CommandNode<S>>
getChildrenCount()
getChildrenCount():
number
Defined in: brigadier/src/tree/CommandNode.ts:60
Returns how many children the node has.
Returns
number
getCommand()
getCommand():
Command<S> |null
Defined in: brigadier/src/tree/CommandNode.ts:50
Returns the command the node runs, or null when the input cannot end on it.
Returns
Command<S> | null
getExamples()
abstractgetExamples():Iterable<string>
Defined in: brigadier/src/tree/CommandNode.ts:215
Returns sample inputs the node accepts, for finding ambiguities.
Returns
Iterable<string>
getName()
abstractgetName():string
Defined in: brigadier/src/tree/CommandNode.ts:162
Returns the node's name, which is unique among its siblings.
Returns
string
getNodeType()
abstractgetNodeType():string
Defined in: brigadier/src/tree/CommandNode.ts:33
Returns the kind of node: literal, argument or root.
Returns
string
getRedirect()
getRedirect():
CommandNode<S> |null
Defined in: brigadier/src/tree/CommandNode.ts:70
Returns the node the input is redirected to, or null.
Returns
CommandNode<S> | null
getRedirectModifier()
getRedirectModifier():
RedirectModifier<S> |null
Defined in: brigadier/src/tree/CommandNode.ts:75
Returns the modifier applied to the source on a redirect, or null.
Returns
RedirectModifier<S> | null
getRelevantNodes()
getRelevantNodes(
input):Iterable<CommandNode<S>>
Defined in: brigadier/src/tree/CommandNode.ts:180
Returns the children worth trying for the next word: the literal it names, or else every argument.
Parameters
input
Returns
Iterable<CommandNode<S>>
getRequirement()
getRequirement():
Predicate<S>
Defined in: brigadier/src/tree/CommandNode.ts:157
Returns the predicate a source must pass to use the node.
Returns
Predicate<S>
getSortedKey()
abstractgetSortedKey():string
Defined in: brigadier/src/tree/CommandNode.ts:177
Returns the key the node sorts by among siblings of the same kind.
Returns
string
getUsageText()
abstractgetUsageText():string
Defined in: brigadier/src/tree/CommandNode.ts:165
Returns how the node appears in a usage string.
Returns
string
isFork()
isFork():
boolean
Defined in: brigadier/src/tree/CommandNode.ts:210
Returns whether the redirect runs once for each source the modifier returns.
Returns
boolean
isValidInput()
abstractisValidInput(input,context):boolean
Defined in: brigadier/src/tree/CommandNode.ts:138
Returns whether the node accepts input.
Parameters
input
string
context
any
Returns
boolean
listSuggestions()
abstractlistSuggestions(context,builder):Promise<Suggestions>
Defined in: brigadier/src/tree/CommandNode.ts:171
Returns the completions the node offers for the input.
Parameters
context
builder
Returns
Promise<Suggestions>
parse()
abstractparse(reader,contextBuilder):void
Defined in: brigadier/src/tree/CommandNode.ts:168
Parses the node's part of the input into the context. Throws on input the node rejects.
Parameters
reader
contextBuilder
Returns
void