Documentation
¶
Overview ¶
Package mcrpc provides allowlist management functionality for Minecraft servers.
Package mcrpc provides ban management functionality for Minecraft servers.
Package mcrpc provides a JSON-RPC 2.0 over WebSocket client for managing Minecraft Java Edition servers. It implements the Minecraft Server Management Protocol (MSMP) and supports server management, player management, bans, operators, allowlists, server settings, and real-time notifications.
A client is built, then started:
client := mcrpc.New("localhost:8080", secret,
mcrpc.WithTLS(nil),
mcrpc.WithHandler(mcrpc.Handler{
OnPlayerJoined: func(p mcrpc.Player) { log.Printf("%s joined", p.Name) },
}),
)
if err := client.Start(ctx); err != nil {
return err
}
defer client.Close()
players, err := client.GetPlayers(ctx)
New performs no I/O, so notification handlers are in place before the connection exists and can never be missed or raced against. The context given to Start bounds the session: cancelling it closes the connection.
Package mcrpc provides game rule management functionality for Minecraft servers.
Package mcrpc provides notification handling functionality for Minecraft servers.
Package mcrpc provides operator management functionality for Minecraft servers.
Package mcrpc provides player management functionality for Minecraft servers.
Package mcrpc provides server management functionality for Minecraft servers.
Package mcrpc provides server settings management functionality for Minecraft servers.
Package mcrpc re-exports the protocol data types so that callers never need to reference the internal packages that define them.
Index ¶
- Constants
- Variables
- func BanUntil(t time.Time) string
- type Client
- func (c *Client) APIVersion(ctx context.Context) (string, error)
- func (c *Client) AddAllowlist(ctx context.Context, add ...Player) ([]Player, error)
- func (c *Client) AddBanlist(ctx context.Context, add ...UserBan) ([]UserBan, error)
- func (c *Client) AddIPBanlist(ctx context.Context, add ...IncomingIPBan) ([]IPBan, error)
- func (c *Client) AddOperators(ctx context.Context, add ...Operator) ([]Operator, error)
- func (c *Client) ClearAllowlist(ctx context.Context) ([]Player, error)
- func (c *Client) ClearBanlist(ctx context.Context) ([]UserBan, error)
- func (c *Client) ClearIPBanlist(ctx context.Context) ([]IPBan, error)
- func (c *Client) ClearOperators(ctx context.Context) ([]Operator, error)
- func (c *Client) Close() error
- func (c *Client) DisconnectNotify() <-chan struct{}
- func (c *Client) GetAcceptTransfers(ctx context.Context) (bool, error)
- func (c *Client) GetAllowFlight(ctx context.Context) (bool, error)
- func (c *Client) GetAllowlist(ctx context.Context) ([]Player, error)
- func (c *Client) GetAutosaveEnabled(ctx context.Context) (bool, error)
- func (c *Client) GetBanlist(ctx context.Context) ([]UserBan, error)
- func (c *Client) GetDifficulty(ctx context.Context) (string, error)
- func (c *Client) GetEnforceAllowlist(ctx context.Context) (bool, error)
- func (c *Client) GetEntityBroadcastRange(ctx context.Context) (int, error)
- func (c *Client) GetForceGameMode(ctx context.Context) (bool, error)
- func (c *Client) GetGameMode(ctx context.Context) (string, error)
- func (c *Client) GetGameRules(ctx context.Context) ([]TypedGameRule, error)
- func (c *Client) GetHideOnlinePlayers(ctx context.Context) (bool, error)
- func (c *Client) GetIPBanlist(ctx context.Context) ([]IPBan, error)
- func (c *Client) GetMOTD(ctx context.Context) (string, error)
- func (c *Client) GetMaxPlayers(ctx context.Context) (int, error)
- func (c *Client) GetOperatorPermissionLevel(ctx context.Context) (int, error)
- func (c *Client) GetOperators(ctx context.Context) ([]Operator, error)
- func (c *Client) GetPauseWhenEmptySeconds(ctx context.Context) (int, error)
- func (c *Client) GetPlayerIdleTimeout(ctx context.Context) (int, error)
- func (c *Client) GetPlayers(ctx context.Context) ([]Player, error)
- func (c *Client) GetServerStatus(ctx context.Context) (ServerState, error)
- func (c *Client) GetSimulationDistance(ctx context.Context) (int, error)
- func (c *Client) GetSpawnProtectionRadius(ctx context.Context) (int, error)
- func (c *Client) GetStatusHeartbeatInterval(ctx context.Context) (int, error)
- func (c *Client) GetStatusReplies(ctx context.Context) (bool, error)
- func (c *Client) GetUseAllowlist(ctx context.Context) (bool, error)
- func (c *Client) GetViewDistance(ctx context.Context) (int, error)
- func (c *Client) IsRunning() bool
- func (c *Client) KickPlayers(ctx context.Context, kick ...KickPlayer) ([]Player, error)
- func (c *Client) RemoveAllowlist(ctx context.Context, remove ...Player) ([]Player, error)
- func (c *Client) RemoveBanlist(ctx context.Context, remove ...Player) ([]UserBan, error)
- func (c *Client) RemoveIPBanlist(ctx context.Context, ip ...string) ([]IPBan, error)
- func (c *Client) RemoveOperators(ctx context.Context, remove ...Player) ([]Operator, error)
- func (c *Client) SaveServer(ctx context.Context, flush bool) (bool, error)
- func (c *Client) SendSystemMessage(ctx context.Context, message SystemMessage) (bool, error)
- func (c *Client) SetAcceptTransfers(ctx context.Context, accept bool) (bool, error)
- func (c *Client) SetAllowFlight(ctx context.Context, allowed bool) (bool, error)
- func (c *Client) SetAllowlist(ctx context.Context, players []Player) ([]Player, error)
- func (c *Client) SetAutosaveEnabled(ctx context.Context, enable bool) (bool, error)
- func (c *Client) SetBanlist(ctx context.Context, bans []UserBan) ([]UserBan, error)
- func (c *Client) SetDifficulty(ctx context.Context, difficulty string) (string, error)
- func (c *Client) SetEnforceAllowlist(ctx context.Context, enforce bool) (bool, error)
- func (c *Client) SetEntityBroadcastRange(ctx context.Context, percentagePoints int) (int, error)
- func (c *Client) SetForceGameMode(ctx context.Context, force bool) (bool, error)
- func (c *Client) SetGameMode(ctx context.Context, mode string) (string, error)
- func (c *Client) SetHideOnlinePlayers(ctx context.Context, hide bool) (bool, error)
- func (c *Client) SetIPBanlist(ctx context.Context, banlist []IPBan) ([]IPBan, error)
- func (c *Client) SetMOTD(ctx context.Context, message string) (string, error)
- func (c *Client) SetMaxPlayers(ctx context.Context, limit int) (int, error)
- func (c *Client) SetOperatorPermissionLevel(ctx context.Context, level int) (int, error)
- func (c *Client) SetOperators(ctx context.Context, operators []Operator) ([]Operator, error)
- func (c *Client) SetPauseWhenEmptySeconds(ctx context.Context, seconds int) (int, error)
- func (c *Client) SetPlayerIdleTimeout(ctx context.Context, seconds int) (int, error)
- func (c *Client) SetSimulationDistance(ctx context.Context, distance int) (int, error)
- func (c *Client) SetSpawnProtectionRadius(ctx context.Context, radius int) (int, error)
- func (c *Client) SetStatusHeartbeatInterval(ctx context.Context, seconds int) (int, error)
- func (c *Client) SetStatusReplies(ctx context.Context, enable bool) (bool, error)
- func (c *Client) SetUseAllowlist(ctx context.Context, use bool) (bool, error)
- func (c *Client) SetViewDistance(ctx context.Context, distance int) (int, error)
- func (c *Client) Start(ctx context.Context) error
- func (c *Client) StopServer(ctx context.Context) (bool, error)
- func (c *Client) UpdateGameRule(ctx context.Context, gamerule UntypedGameRule) (TypedGameRule, error)
- type Error
- type Handler
- type IPBan
- type IncomingIPBan
- type KickPlayer
- type Message
- type Operator
- type Option
- type Player
- type ServerState
- type SystemMessage
- type TraceDirection
- type TraceMessage
- type TypedGameRule
- type UntypedGameRule
- type UserBan
- type Version
Constants ¶
const BanTimeFormat = types.BanTimeFormat
BanTimeFormat is the layout the management protocol uses for ban expiry timestamps.
const DefaultHandshakeTimeout = 10 * time.Second
DefaultHandshakeTimeout bounds the WebSocket handshake performed by Start unless WithHandshakeTimeout says otherwise.
Variables ¶
var ErrAlreadyStarted = errors.New("mcrpc: client is already started")
ErrAlreadyStarted is returned by Start when the client already holds a connection. Close it before starting a new session.
var ErrNotConnected = errors.New("mcrpc: client is not connected")
ErrNotConnected is returned when a call is attempted on a client that has not been started, or whose session has ended.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a Minecraft server over JSON-RPC 2.0 on a WebSocket.
New only builds the value; nothing is dialled and no goroutine runs until Start. That split is what makes notification handlers safe to register: WithHandler is applied before any receive goroutine exists.
A Client is safe for concurrent use, and can be restarted: after Close, a further Start dials again with the same configuration and handler.
func New ¶
New builds a client for the management server at addr, a "host:port" pair. It performs no I/O; call Start to connect.
secret is the value of management-server-secret in server.properties. Without any option the connection is plaintext ws; see WithTLS.
func NewHostPort ¶
NewHostPort is New for callers that hold the host and port separately.
func (*Client) APIVersion ¶
APIVersion returns the version of the management API the server implements, as advertised by rpc.discover.
This is the version protocol behaviour is keyed on, not the Minecraft version: 1.0.0 ships with 1.21.9, 3.0.0 with 26.2, and 3.1.0 with 26.3, which is what added the world upgrade notifications. Game rule values, for example, are strings before 3.0.0 and native JSON types from 3.0.0 on.
func (*Client) AddAllowlist ¶
AddAllowlist adds the specified players to the allowlist.
func (*Client) AddBanlist ¶
AddBanlist adds the specified bans to the ban list.
func (*Client) AddIPBanlist ¶
AddIPBanlist adds the specified IP bans to the ban list.
func (*Client) AddOperators ¶
AddOperators adds the specified players as operators.
func (*Client) ClearAllowlist ¶
ClearAllowlist removes all players from the allowlist.
func (*Client) ClearBanlist ¶
ClearBanlist removes all bans from the ban list.
func (*Client) ClearIPBanlist ¶
ClearIPBanlist removes all IP bans from the ban list.
func (*Client) ClearOperators ¶
ClearOperators removes all players from the operator list.
func (*Client) Close ¶
Close ends the session and releases the connection. It is safe to call multiple times and on a client that was never started, and it does not prevent a later Start from reconnecting.
func (*Client) DisconnectNotify ¶
func (c *Client) DisconnectNotify() <-chan struct{}
DisconnectNotify returns a channel closed when the current session ends.
The channel belongs to one session: after a Close and a further Start, call this again to observe the new one. For a client that is not running, the returned channel is already closed.
func (*Client) GetAcceptTransfers ¶
GetAcceptTransfers retrieves whether the server accepts player transfers.
func (*Client) GetAllowFlight ¶
GetAllowFlight retrieves whether flight is allowed in Survival mode.
func (*Client) GetAllowlist ¶
GetAllowlist retrieves the current allowlist of players.
func (*Client) GetAutosaveEnabled ¶
GetAutosaveEnabled retrieves whether automatic world saving is enabled.
func (*Client) GetBanlist ¶
GetBanlist retrieves the current list of banned players.
func (*Client) GetDifficulty ¶
GetDifficulty retrieves the current difficulty level of the server.
func (*Client) GetEnforceAllowlist ¶
GetEnforceAllowlist retrieves whether allowlist enforcement is enabled.
func (*Client) GetEntityBroadcastRange ¶
GetEntityBroadcastRange retrieves the entity broadcast range percentage.
func (*Client) GetForceGameMode ¶
GetForceGameMode retrieves whether players are forced to use the default game mode.
func (*Client) GetGameMode ¶
GetGameMode retrieves the server's default game mode.
func (*Client) GetGameRules ¶
func (c *Client) GetGameRules(ctx context.Context) ([]TypedGameRule, error)
GetGameRules retrieves all game rules and their current values.
func (*Client) GetHideOnlinePlayers ¶
GetHideOnlinePlayers retrieves whether online player info is hidden from status queries.
func (*Client) GetIPBanlist ¶
GetIPBanlist retrieves the current list of banned IP addresses.
func (*Client) GetMaxPlayers ¶
GetMaxPlayers retrieves the maximum number of players allowed on the server.
func (*Client) GetOperatorPermissionLevel ¶
GetOperatorPermissionLevel retrieves the operator permission level.
func (*Client) GetOperators ¶
GetOperators retrieves the current list of operators.
func (*Client) GetPauseWhenEmptySeconds ¶
GetPauseWhenEmptySeconds retrieves the pause when empty timeout in seconds.
func (*Client) GetPlayerIdleTimeout ¶
GetPlayerIdleTimeout retrieves the player idle timeout in seconds.
func (*Client) GetPlayers ¶
GetPlayers retrieves the list of currently online players.
func (*Client) GetServerStatus ¶
func (c *Client) GetServerStatus(ctx context.Context) (ServerState, error)
GetServerStatus retrieves the current status of the server including online players and version information.
func (*Client) GetSimulationDistance ¶
GetSimulationDistance retrieves the simulation distance in chunks.
func (*Client) GetSpawnProtectionRadius ¶
GetSpawnProtectionRadius retrieves the spawn protection radius in blocks.
func (*Client) GetStatusHeartbeatInterval ¶
GetStatusHeartbeatInterval retrieves the status heartbeat interval in seconds.
func (*Client) GetStatusReplies ¶
GetStatusReplies retrieves whether the server responds to status requests.
func (*Client) GetUseAllowlist ¶
GetUseAllowlist retrieves whether the allowlist is enabled.
func (*Client) GetViewDistance ¶
GetViewDistance retrieves the view distance in chunks.
func (*Client) IsRunning ¶
IsRunning reports whether the client currently holds a live connection.
A session that has dropped reports false straight away, without waiting for the watchdog to clear the client's state.
func (*Client) KickPlayers ¶
KickPlayers kicks the specified players from the server with custom messages.
func (*Client) RemoveAllowlist ¶
RemoveAllowlist removes the specified players from the allowlist.
func (*Client) RemoveBanlist ¶
RemoveBanlist removes the specified players from the ban list.
func (*Client) RemoveIPBanlist ¶
RemoveIPBanlist removes the specified IP addresses from the ban list.
func (*Client) RemoveOperators ¶
RemoveOperators removes the specified players from the operator list.
func (*Client) SaveServer ¶
SaveServer saves the current server state. If flush is true, all pending changes are flushed to disk.
func (*Client) SendSystemMessage ¶
SendSystemMessage sends a system message to the specified players on the server.
func (*Client) SetAcceptTransfers ¶
SetAcceptTransfers sets whether the server accepts player transfers.
func (*Client) SetAllowFlight ¶
SetAllowFlight sets whether flight is allowed in Survival mode.
func (*Client) SetAllowlist ¶
SetAllowlist sets the allowlist to the specified list of players, replacing the existing list.
func (*Client) SetAutosaveEnabled ¶
SetAutosaveEnabled enables or disables automatic world saving.
func (*Client) SetBanlist ¶
SetBanlist sets the ban list to the specified list of bans, replacing the existing list.
func (*Client) SetDifficulty ¶
SetDifficulty sets the difficulty level of the server (peaceful, easy, normal, hard).
func (*Client) SetEnforceAllowlist ¶
SetEnforceAllowlist enables or disables allowlist enforcement.
func (*Client) SetEntityBroadcastRange ¶
SetEntityBroadcastRange sets the entity broadcast range percentage.
func (*Client) SetForceGameMode ¶
SetForceGameMode sets whether players are forced to use the default game mode.
func (*Client) SetGameMode ¶
SetGameMode sets the server's default game mode (creative, survival, spectator, adventure).
func (*Client) SetHideOnlinePlayers ¶
SetHideOnlinePlayers sets whether online player info is hidden from status queries.
func (*Client) SetIPBanlist ¶
SetIPBanlist sets the IP ban list to the specified list, replacing the existing list.
func (*Client) SetMaxPlayers ¶
SetMaxPlayers sets the maximum number of players allowed on the server.
func (*Client) SetOperatorPermissionLevel ¶
SetOperatorPermissionLevel sets the operator permission level.
func (*Client) SetOperators ¶
SetOperators sets the operator list to the specified list, replacing the existing list.
func (*Client) SetPauseWhenEmptySeconds ¶
SetPauseWhenEmptySeconds sets the pause when empty timeout in seconds.
func (*Client) SetPlayerIdleTimeout ¶
SetPlayerIdleTimeout sets the player idle timeout in seconds.
func (*Client) SetSimulationDistance ¶
SetSimulationDistance sets the simulation distance in chunks.
func (*Client) SetSpawnProtectionRadius ¶
SetSpawnProtectionRadius sets the spawn protection radius in blocks.
func (*Client) SetStatusHeartbeatInterval ¶
SetStatusHeartbeatInterval sets the status heartbeat interval in seconds.
func (*Client) SetStatusReplies ¶
SetStatusReplies sets whether the server responds to status requests.
func (*Client) SetUseAllowlist ¶
SetUseAllowlist enables or disables the allowlist.
func (*Client) SetViewDistance ¶
SetViewDistance sets the view distance in chunks.
func (*Client) Start ¶
Start dials the server and begins dispatching notifications. It returns ErrAlreadyStarted if the client is already connected.
ctx bounds the whole session, not just the handshake: cancelling it closes the connection. To bound only the handshake use WithHandshakeTimeout, and pass a context that outlives the session here.
func (*Client) StopServer ¶
StopServer stops the Minecraft server.
func (*Client) UpdateGameRule ¶
func (c *Client) UpdateGameRule(ctx context.Context, gamerule UntypedGameRule) (TypedGameRule, error)
UpdateGameRule updates the value of a specific game rule.
type Error ¶
type Error struct {
// Method is the JSON-RPC method that failed.
Method string
// Code is the JSON-RPC error code, or 0 if the call failed before the
// server produced a response (transport errors, closed connection).
Code int64
// Message is the error message reported by the server, if any.
Message string
// Data is the optional payload the server attached to the error.
Data *json.RawMessage
// contains filtered or unexported fields
}
Error describes a failed remote call. Every error returned by a Client method wraps the underlying cause, so errors.Is and errors.As both work:
var rpcErr *mcrpc.Error
if errors.As(err, &rpcErr) && rpcErr.Code == -32602 {
// the server rejected the parameters
}
type Handler ¶
type Handler struct {
// OnNotification is called for every notification, before any specific
// callback below. It receives the raw params, which are nil if the
// notification carried none.
OnNotification func(method string, params json.RawMessage)
// OnError is called when a notification arrives but its params cannot be
// decoded into the expected type. Without it such notifications are
// dropped silently.
OnError func(method string, err error)
// Server notifications
OnServerStarted func()
OnServerStopping func()
OnServerSaving func()
OnServerSaved func()
OnServerStatus func(status ServerState)
OnServerActivity func()
// Player notifications
OnPlayerJoined func(player Player)
OnPlayerLeft func(player Player)
// Operator notifications
OnOperatorAdded func(operator Operator)
OnOperatorRemoved func(operator Operator)
// Allowlist notifications
OnAllowlistAdded func(player Player)
OnAllowlistRemoved func(player Player)
// Ban notifications
OnBanAdded func(ban UserBan)
OnBanRemoved func(player Player)
// IP ban notifications
OnIPBanAdded func(ban IPBan)
OnIPBanRemoved func(ip string)
// Gamerule notifications
OnGameruleUpdated func(gamerule TypedGameRule)
// World notifications
OnWorldUpgradeStarted func()
OnWorldUpgradeProgress func(progress float64)
OnWorldUpgradeFinished func()
OnWorldUpgradeFailed func(reason string)
}
Handler is the set of callbacks invoked for notifications pushed by the server. Every field is optional; a nil callback means the notification is ignored.
A Handler is passed to New via WithHandler and copied into the client, so mutating your own copy afterwards has no effect on a running client. This is deliberate: the connection's receive goroutine reads these callbacks concurrently, and copying them once at construction keeps that read race-free.
The context passed to a callback is the one given to Start. It is cancelled when the session ends, so a callback that makes further calls should pass it along and expect cancellation.
type IncomingIPBan ¶
type IncomingIPBan = types.IncomingIPBan
IncomingIPBan is an alias for types.IncomingIPBan, representing an incoming IP ban with player information.
type KickPlayer ¶
type KickPlayer = types.KickPlayer
KickPlayer is an alias for types.KickPlayer, representing a player to be kicked with a message.
type Message ¶
Message is an alias for types.Message, representing a translatable or literal message that can be sent to players.
func LiteralMessage ¶
LiteralMessage builds a message carrying plain text.
func TranslatableMessage ¶
TranslatableMessage builds a message the client renders from a translation key, substituting params in order.
type Option ¶
type Option func(*Client)
An Option configures a Client. Options are applied by New and are order-independent: the TLS settings they touch are combined into a single configuration when Start dials.
func WithClientCertificate ¶
func WithClientCertificate(cert tls.Certificate) Option
WithClientCertificate makes the client connect over wss and present cert for client certificate authentication. It implies WithTLS.
func WithHandler ¶
WithHandler registers the callbacks invoked for server notifications. The handler is copied, so it must be complete at construction time; see Handler for why.
func WithHandshakeTimeout ¶
WithHandshakeTimeout caps how long Start waits for the WebSocket handshake. A non-positive duration removes the cap, leaving the context passed to Start as the only bound. Defaults to DefaultHandshakeTimeout.
func WithInsecureSkipVerify ¶
func WithInsecureSkipVerify() Option
WithInsecureSkipVerify disables verification of the server's certificate and implies WithTLS.
This makes the connection vulnerable to interception: the client will accept any certificate the server offers, including one presented by an attacker. Use it only against servers with self-signed certificates on a network you control.
func WithTLS ¶
WithTLS makes the client connect over wss using cfg. A nil cfg selects TLS with default settings, which is what a server that presents a certificate but does not require client authentication needs.
cfg is cloned when the option is applied, so later changes to your copy do not affect the client. That matters beyond tidiness: without it a config shared with something else could turn InsecureSkipVerify on after the client was built, and every dial from then on — including reconnects — would follow.
func WithTrace ¶
func WithTrace(trace func(TraceMessage)) Option
WithTrace reports every JSON-RPC message the client sends and receives, with params and results exactly as they were serialised.
This is a diagnostic aid for confirming what the client puts on the wire and what the server sends back — struct tags, omitted fields, and the JSON types of untyped values. It is called from the connection's read and write paths, so it must not block or call back into the client.
Params may contain the server secret if a future method carries one; treat trace output as sensitive.
type Player ¶
Player is an alias for types.Player, representing a Minecraft player.
func PlayerByName ¶
PlayerByName identifies a player by username, for calls where the server resolves the UUID itself.
func PlayerByUUID ¶
PlayerByUUID identifies a player by UUID, for calls where the username is unknown or may have changed.
type ServerState ¶
type ServerState = types.ServerState
ServerState is an alias for types.ServerState, representing the current state of the server.
type SystemMessage ¶
type SystemMessage = types.SystemMessage
SystemMessage is an alias for types.SystemMessage, representing a message broadcast to a set of players.
type TraceDirection ¶
type TraceDirection int
TraceDirection reports which way a traced message travelled.
const ( // TraceSent marks a message the client wrote to the server. TraceSent TraceDirection = iota // TraceReceived marks a message the client read from the server. TraceReceived )
func (TraceDirection) String ¶
func (d TraceDirection) String() string
String renders the direction as an arrow, for log output.
type TraceMessage ¶
type TraceMessage struct {
// Direction is TraceSent or TraceReceived.
Direction TraceDirection
// Method names the call or notification. It is empty for a response,
// unless the originating request is still known, in which case it names
// that request's method.
Method string
// ID is the JSON-RPC request id, empty for a notification.
ID string
// Notification reports whether this message expects no response.
Notification bool
// Params is the request payload as sent or received, nil when absent.
Params json.RawMessage
// Result is the response payload, nil for requests and for error
// responses.
Result json.RawMessage
// ErrorCode and ErrorMessage describe an error response. ErrorCode is 0
// when the message is not an error.
ErrorCode int64
ErrorMessage string
}
TraceMessage is one JSON-RPC message observed on the connection, carrying the params and result exactly as they were serialised. It is intended for diagnosing protocol mismatches: what a struct tag actually produces, and what JSON type a field actually arrives as.
func (TraceMessage) IsError ¶
func (m TraceMessage) IsError() bool
IsError reports whether the message is an error response.
func (TraceMessage) String ¶
func (m TraceMessage) String() string
String renders the message as one line, suitable for passing straight to a logger:
-> minecraft:allowlist/add #3 {"add":[{"name":"fi_xz","id":""}]}
<- #3 [{"name":"fi_xz","id":"a0d8c884-..."}]
<- notify minecraft:notification/players/joined {"name":"fi_xz",...}
type TypedGameRule ¶
type TypedGameRule = types.TypedGameRule
TypedGameRule is an alias for types.TypedGameRule, representing a game rule with a typed value.
type UntypedGameRule ¶
type UntypedGameRule = types.UntypedGameRule
UntypedGameRule is an alias for types.UntypedGameRule, representing a game rule value whose type is not declared.
func BoolRule ¶
func BoolRule(key string, value bool) UntypedGameRule
BoolRule builds a game rule update carrying a boolean value.
func IntRule ¶
func IntRule(key string, value int) UntypedGameRule
IntRule builds a game rule update carrying an integer value.
func StringRule ¶
func StringRule(key, value string) UntypedGameRule
StringRule builds a game rule update carrying a string value.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
protocol
Package protocol contains request parameter types for Minecraft Server Management Protocol methods.
|
Package protocol contains request parameter types for Minecraft Server Management Protocol methods. |
|
types
Package types contains data types used by the Minecraft Server Management Protocol.
|
Package types contains data types used by the Minecraft Server Management Protocol. |