API reference / @jsprismarine/prismarine / CommandManager
Class: CommandManager
Defined in: prismarine/src/command/CommandManager.ts:55
Implements
Constructors
Constructor
new CommandManager(
server,onStopCommandComplete?):CommandManager
Defined in: prismarine/src/command/CommandManager.ts:90
Parameters
server
onStopCommandComplete?
() => void
Returns
CommandManager
Methods
dispatchCommand()
dispatchCommand(
sender,target,input?):Promise<boolean>
Defined in: prismarine/src/command/CommandManager.ts:590
Dispatches a command and executes it.
Parameters
sender
the player/console who executed the command
target
the Player/entity/console who should execute the command
input?
string = ''
the command input including arguments
Returns
Promise<boolean>
True when the command ran. False when the target cannot run commands, the sender lacks the permission, the command is unknown, or it threw; in each of those cases the sender has been sent the reason.
getFunctionRuntime()
getFunctionRuntime():
FunctionRuntime
Defined in: prismarine/src/command/CommandManager.ts:127
The mcfunction runtime this server's /function and /schedule run through.
Returns
FunctionRuntime
The runtime, holding whatever functions the loaded datapacks declared - which is none when the stack has no datapack in it.
getVanillaCommandList()
getVanillaCommandList(): readonly
FlattenedCommand[]
Defined in: prismarine/src/command/CommandManager.ts:284
The vanilla command set flattened into Bedrock's overload shape.
The tree is immutable after build, so every recipient shares this unfiltered flattened view. Recipient-specific permission checks happen after this accessor, while the packet is assembled.
Returns
readonly FlattenedCommand[]
One entry per command, aliases folded in.
getVanillaCommands()
getVanillaCommands():
CommandRegistry<CommandSource>
Defined in: prismarine/src/command/CommandManager.ts:272
The vanilla command set, for the session that has to advertise it.
Returns
CommandRegistry<CommandSource>
restoreRandomSequenceState()
restoreRandomSequenceState(
state):void
Defined in: prismarine/src/command/CommandManager.ts:109
Restores command random streams for the same default world.
Parameters
state
unknown
Returns
void
runLoadFunctions()
runLoadFunctions():
Promise<number>
Defined in: prismarine/src/command/CommandManager.ts:217
Runs #minecraft:load, which a server does once after its packs load.
Returns
Promise<number>
How many command lines ran.
saveRandomSequenceState()
saveRandomSequenceState():
RandomSequencesState
Defined in: prismarine/src/command/CommandManager.ts:104
Captures the persistent command random streams for a replay baseline.
Returns
RandomSequencesState
setFunctionContent()
setFunctionContent(
content?):void
Defined in: prismarine/src/command/CommandManager.ts:150
Replaces the functions this server runs and drops the compiled ones.
Parameters
content?
FunctionContent
Where to compile functions from. Undefined goes back to the server's own content, which is what a reload wants; a caller that loaded a datapack itself passes its registries.
Returns
void
tickFunctions()
tickFunctions():
Promise<number>
Defined in: prismarine/src/command/CommandManager.ts:200
Runs #minecraft:tick and whatever /schedule put on this tick.
Called once per server tick from the tick loop. Nothing here is awaited by a sender, so the work the lines park is collected and awaited here instead.
Returns
Promise<number>
How many command lines ran.
usageLines()
usageLines(
target?): readonlystring[]
Defined in: prismarine/src/command/CommandManager.ts:314
Builds a help page or describes a command route from the Java-shaped tree.
A numeric target selects a list page. Any other target is a command name followed by zero or more literal subcommands, such as locate structure. This walks the source tree directly, so recursive routes such as /execute do not need to be expanded into Bedrock overloads first.
Parameters
target?
string
A page number or command route, or undefined for page 1.
Returns
readonly string[]
Formatted help lines for the requested page or route.
vanillaName()
vanillaName(
name):string|undefined
Defined in: prismarine/src/command/CommandManager.ts:296
The command a name or alias belongs to in the vanilla set.
Parameters
name
string
The first word of a command line, without the slash.
Returns
string | undefined
The owning command's name, or undefined when the vanilla set does not hold it.
Lifecycle
disable()
disable():
Promise<void>
Defined in: prismarine/src/command/CommandManager.ts:269
On disable hook.
Returns
Promise<void>
Implementation of
enable()
enable():
Promise<void>
Defined in: prismarine/src/command/CommandManager.ts:246
On enable hook.
Returns
Promise<void>