Go: Commands¶
Functions¶
ExecuteCommand¶
| Go | |
|---|---|
ExecuteCommand runs cmd as the console and returns what it printed. Server thread only. An error means the level is not ready, or the host cannot run commands.
- Parameters:
- cmd :
string
- cmd :
- Return type:
([]CommandOutput, error) - Slots:
execute_command
RegisterCommand¶
| Go | |
|---|---|
RegisterCommand registers /name, whose text after the name reaches fn as Args. Call it from Enable, on the server thread. A command stays registered while the server runs, since Bedrock cannot unregister one; the host mutes it while the mod is disabled.
- Parameters:
- name :
string - description :
string - permission :
Permission - fn :
func(*Invocation)
- name :
- Return type:
error - Slots:
register_command
NewOverload¶
| Go | |
|---|---|
NewOverload begins an overload.
- Return type:
*Overload
NewCommand¶
| Go | |
|---|---|
NewCommand begins declaring /name.
- Parameters:
- name :
string - description :
string - permission :
Permission
- name :
- Return type:
*CommandBuilder
RegisterCommandEnum¶
| Go | |
|---|---|
RegisterCommandEnum registers a fixed enum for RequiredEnum and OptionalEnum.
- Parameters:
- name :
string - values :
[]EnumValue
- name :
- Return type:
error - Slots:
register_command_enum
RegisterSoftEnum¶
| Go | |
|---|---|
RegisterSoftEnum registers an enum whose values can change while the server runs.
- Parameters:
- name :
string - values :
[]string
- name :
- Return type:
error - Slots:
register_command_soft_enum
UpdateSoftEnum¶
| Go | |
|---|---|
UpdateSoftEnum replaces, adds to or removes from the values of a soft enum.
- Parameters:
- name :
string - op :
SoftEnumOp - values :
[]string
- name :
- Return type:
error - Slots:
update_command_soft_enum
CommandCall¶
| Go | |
|---|---|
CommandCall is one run of a command declared with CommandBuilder.
CommandCall.Arg¶
| Go | |
|---|---|
Arg is a named argument, and false for an optional one left out.
- Parameters:
- name :
string
- name :
- Return type:
(*Nbt, bool)
CommandCall.ArgString¶
| Go | |
|---|---|
ArgString is a named argument as text.
- Parameters:
- name :
string
- name :
- Return type:
(string, bool)
CommandCall.ArgInt¶
| Go | |
|---|---|
ArgInt is a named integer argument.
- Parameters:
- name :
string
- name :
- Return type:
(int64, bool)
CommandCall.ArgFloat¶
| Go | |
|---|---|
ArgFloat is a named number argument.
- Parameters:
- name :
string
- name :
- Return type:
(float64, bool)
CommandCall.IsConsole¶
| Go | |
|---|---|
IsConsole reports whether the dedicated server console ran the command.
- Return type:
bool
CommandCall.Success¶
| Go | |
|---|---|
Success sends a line of output.
- Parameters:
- msg :
string
- msg :
CommandCall.Error¶
| Go | |
|---|---|
Error sends a line of error output.
- Parameters:
- msg :
string
- msg :
Overload¶
Overload is one way a command parses: its parameters in order.
Overload.Required¶
| Go | |
|---|---|
Required adds a parameter that must be given.
- Parameters:
- name :
string - t :
ParamType
- name :
- Return type:
*Overload
Overload.Optional¶
| Go | |
|---|---|
Optional adds a parameter that may be left out; Arg answers false for it then.
- Parameters:
- name :
string - t :
ParamType
- name :
- Return type:
*Overload
Overload.RequiredEnum¶
| Go | |
|---|---|
RequiredEnum adds an enum parameter, which RegisterCommandEnum or RegisterSoftEnum registered first.
- Parameters:
- name :
string - t :
ParamType - enum :
string
- name :
- Return type:
*Overload
Overload.OptionalEnum¶
| Go | |
|---|---|
OptionalEnum adds an enum parameter that may be left out.
- Parameters:
- name :
string - t :
ParamType - enum :
string
- name :
- Return type:
*Overload
Overload.Text¶
| Go | |
|---|---|
Text adds a literal word, the shape /scoreboard objectives add is made of. The word comes back among the arguments under name, so a handler reads it like any other parameter. Sibling words taking the same arguments are one enum instead (contract section 6.1).
- Parameters:
- name :
string - literal :
string
- name :
- Return type:
*Overload
Invocation¶
| Go | |
|---|---|
Invocation is one run of a command. Success and Error may be called any number of times during the callback and not after it returns.
Invocation.Success¶
| Go | |
|---|---|
Success sends a line of output.
- Parameters:
- msg :
string
- msg :
Invocation.Error¶
| Go | |
|---|---|
Error sends a line of error output.
- Parameters:
- msg :
string
- msg :
CommandBuilder¶
CommandBuilder declares a command with typed overloads. Each overload must parse a different input: two that accept the same words leave the engine to pick one.
CommandBuilder.Overload¶
| Go | |
|---|---|
Overload adds one way the command parses.
- Parameters:
- o :
*Overload
- o :
- Return type:
*CommandBuilder
CommandBuilder.Register¶
| Go | |
|---|---|
Register registers the command. fn runs on the server thread for every run; a payload the binding cannot parse is reported to whoever ran the command and fn does not run.
- Parameters:
- fn :
func(*CommandCall)
- fn :
- Return type:
error - Slots:
register_command_ex
CommandOutput¶
CommandOutput is one line a command printed.
Permission¶
| Go | |
|---|---|
Permission is who may run a command; it mirrors CommandPermissionLevel.
| Name | Value | Description |
|---|---|---|
PermissionAny |
0 |
|
PermissionGameDirectors |
1 |
|
PermissionAdmin |
2 |
|
PermissionHost |
3 |
|
PermissionOwner |
4 |
ParamType¶
| Go | |
|---|---|
ParamType is the type of one command parameter, the kind words of register_command_ex.
| Name | Value | Description |
|---|---|---|
ParamInt |
"int" |
|
ParamBool |
"bool" |
|
ParamFloat |
"float" |
|
ParamString |
"string" |
|
ParamEnum |
"enum" |
|
ParamSoftEnum |
"soft_enum" |
|
ParamActor |
"actor" |
|
ParamPlayer |
"player" |
|
ParamBlockPos |
"block_pos" |
|
ParamVec3 |
"vec3" |
|
ParamRawText |
"raw_text" |
|
ParamMessage |
"message" |
|
ParamJSON |
"json" |
|
ParamItem |
"item" |
|
ParamBlockName |
"block_name" |
|
ParamEffect |
"effect" |
|
ParamActorType |
"actor_type" |
|
ParamCommand |
"command" |
|
ParamRelativeFloat |
"relative_float" |
|
ParamFilePath |
"file_path" |
CommandOrigin¶
| Go | |
|---|---|
CommandOrigin is who ran a command and where.
EnumValue¶
EnumValue is one value of a command enum.
SoftEnumOp¶
| Go | |
|---|---|
SoftEnumOp is how UpdateSoftEnum changes the values.
| Name | Value | Description |
|---|---|---|
SoftEnumSet |
0 |
|
SoftEnumAdd |
1 |
|
SoftEnumRemove |
2 |