API reference / @jsprismarine/commands / CommandRegistry
Class: CommandRegistry<S>
Defined in: commands/src/tree.ts:96
A command tree plus the metadata the Bedrock packet needs.
The dispatcher is the Brigadier port's, unchanged, so Java fork and redirect semantics run server-side exactly as upstream defines them.
Type Parameters
S
S
Constructors
Constructor
new CommandRegistry<
S>(options?):CommandRegistry<S>
Defined in: commands/src/tree.ts:105
Parameters
options?
Returns
CommandRegistry<S>
Methods
getAliasOwner()
getAliasOwner(
name):string|undefined
Defined in: commands/src/tree.ts:214
The command an alias stands for.
Parameters
name
string
Returns
string | undefined
The owning command's name, or undefined when the name is not an alias.
getContent()
getContent():
ContentRegistryIds
Defined in: commands/src/tree.ts:119
What the host's own registries hold, for the registry arguments that validate against live content.
Read by the command builders rather than passed to each of them: the registry is the one object every builder already has.
Returns
The lists the caller gave, or an empty set of them.
getDispatcher()
getDispatcher():
CommandDispatcher<S>
Defined in: commands/src/tree.ts:176
The Brigadier dispatcher the registry builds into.
Returns
getExcludedNames()
getExcludedNames():
string[]
Defined in: commands/src/tree.ts:205
The names CommandRegistryOptions.include turned away.
Worth reporting rather than hiding: it is the difference between the command set a package implements and the one a particular host can run.
Returns
string[]
getMetadata()
getMetadata(
name):CommandMetadata|undefined
Defined in: commands/src/tree.ts:190
The metadata of one command.
Parameters
name
string
Returns
CommandMetadata | undefined
The metadata, or undefined for an alias or an unknown name.
getNames()
getNames():
string[]
Defined in: commands/src/tree.ts:195
Every registered command name, aliases excluded, in registration order.
Returns
string[]
getRoot()
getRoot():
RootCommandNode<S>
Defined in: commands/src/tree.ts:181
The tree's root node, the one the flattener walks.
Returns
register()
register(
builder,metadata?):LiteralCommandNode<S>
Defined in: commands/src/tree.ts:137
Registers one command and every alias it answers to.
Each alias becomes a literal that redirects to the real root and shares its executor, so /tp and /teleport parse the same arguments and run the same code.
Parameters
builder
The command's root literal, already built up.
metadata?
CommandMetadataInput = {}
Returns
The registered root node, or the built but unregistered node when CommandRegistryOptions.include excluded the name. A caller that chains onto the result, as /execute does, then builds a branch nothing can reach, which is the point.
Throws
When the name or one of its aliases is already taken.