Documentation
¶
Overview ¶
Package mcrpc provides allowlist management functionality for Minecraft servers.
Package mcrpc provides ban management functionality for Minecraft servers.
Package mcrpc provides game rule 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.
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.
Index ¶
- type IPBan
- type IncomingIPBan
- type KickPlayer
- type MCRPCClient
- func (c *MCRPCClient) AddAllowlist(context context.Context, add []Player) ([]Player, error)
- func (c *MCRPCClient) AddBanlist(context context.Context, add []UserBan) ([]UserBan, error)
- func (c *MCRPCClient) AddIPBanlist(context context.Context, add []IncomingIPBan) ([]IPBan, error)
- func (c *MCRPCClient) AddOperators(context context.Context, add []Operator) ([]Operator, error)
- func (c *MCRPCClient) ClearAllowlist(context context.Context) ([]Player, error)
- func (c *MCRPCClient) ClearBanlist(context context.Context) ([]UserBan, error)
- func (c *MCRPCClient) ClearIPBanlist(context context.Context) ([]IPBan, error)
- func (c *MCRPCClient) ClearOperators(context context.Context) ([]Operator, error)
- func (c *MCRPCClient) Close() error
- func (c *MCRPCClient) DisconnectNotify() <-chan struct{}
- func (c *MCRPCClient) GetAcceptTransfers(context context.Context) (bool, error)
- func (c *MCRPCClient) GetAllowFlight(context context.Context) (bool, error)
- func (c *MCRPCClient) GetAllowlist(context context.Context) ([]Player, error)
- func (c *MCRPCClient) GetAutosaveEnabled(context context.Context) (bool, error)
- func (c *MCRPCClient) GetBanlist(context context.Context) ([]UserBan, error)
- func (c *MCRPCClient) GetDifficulty(context context.Context) (string, error)
- func (c *MCRPCClient) GetEnforceAllowlist(context context.Context) (bool, error)
- func (c *MCRPCClient) GetEntityBroadcastRange(context context.Context) (int, error)
- func (c *MCRPCClient) GetForceGameMode(context context.Context) (bool, error)
- func (c *MCRPCClient) GetGameMode(context context.Context) (string, error)
- func (c *MCRPCClient) GetGameRules(context context.Context) ([]TypedGameRule, error)
- func (c *MCRPCClient) GetHideOnlinePlayers(context context.Context) (bool, error)
- func (c *MCRPCClient) GetIPBanlist(context context.Context) ([]IPBan, error)
- func (c *MCRPCClient) GetMOTD(context context.Context) (string, error)
- func (c *MCRPCClient) GetMaxPlayers(context context.Context) (int, error)
- func (c *MCRPCClient) GetOperatorPermissionLevel(context context.Context) (int, error)
- func (c *MCRPCClient) GetOperators(context context.Context) ([]Operator, error)
- func (c *MCRPCClient) GetPauseWhenEmptySeconds(context context.Context) (int, error)
- func (c *MCRPCClient) GetPlayerIdleTimeout(context context.Context) (int, error)
- func (c *MCRPCClient) GetPlayers(context context.Context) ([]Player, error)
- func (c *MCRPCClient) GetServerStatus(context context.Context) (ServerState, error)
- func (c *MCRPCClient) GetSimulationDistance(context context.Context) (int, error)
- func (c *MCRPCClient) GetSpawnProtectionRadius(context context.Context) (int, error)
- func (c *MCRPCClient) GetStatusHeartbeatInterval(context context.Context) (int, error)
- func (c *MCRPCClient) GetStatusReplies(context context.Context) (bool, error)
- func (c *MCRPCClient) GetUseAllowlist(context context.Context) (bool, error)
- func (c *MCRPCClient) GetViewDistance(context context.Context) (int, error)
- func (c *MCRPCClient) IsClosed() bool
- func (c *MCRPCClient) KickPlayers(context context.Context, kick []KickPlayer) ([]Player, error)
- func (c *MCRPCClient) RemoveAllowlist(context context.Context, remove []Player) ([]Player, error)
- func (c *MCRPCClient) RemoveBanlist(context context.Context, remove []Player) ([]UserBan, error)
- func (c *MCRPCClient) RemoveIPBanlist(context context.Context, ip []string) ([]IPBan, error)
- func (c *MCRPCClient) RemoveOperators(context context.Context, remove []Player) ([]Operator, error)
- func (c *MCRPCClient) SaveServer(context context.Context, flush bool) (bool, error)
- func (c *MCRPCClient) SendSystemMessage(context context.Context, message types.SystemMessage) (bool, error)
- func (c *MCRPCClient) SetAcceptTransfers(context context.Context, accept bool) (bool, error)
- func (c *MCRPCClient) SetAllowFlight(context context.Context, allowed bool) (bool, error)
- func (c *MCRPCClient) SetAllowlist(context context.Context, players []Player) ([]Player, error)
- func (c *MCRPCClient) SetAutosaveEnabled(context context.Context, enable bool) (bool, error)
- func (c *MCRPCClient) SetBanlist(context context.Context, bans []UserBan) ([]UserBan, error)
- func (c *MCRPCClient) SetDifficulty(context context.Context, difficulty string) (string, error)
- func (c *MCRPCClient) SetEnforceAllowlist(context context.Context, enforce bool) (bool, error)
- func (c *MCRPCClient) SetEntityBroadcastRange(context context.Context, percentagePoints int) (int, error)
- func (c *MCRPCClient) SetForceGameMode(context context.Context, force bool) (bool, error)
- func (c *MCRPCClient) SetGameMode(context context.Context, mode string) (string, error)
- func (c *MCRPCClient) SetHideOnlinePlayers(context context.Context, hide bool) (bool, error)
- func (c *MCRPCClient) SetIPBanlist(context context.Context, banlist []IPBan) ([]IPBan, error)
- func (c *MCRPCClient) SetMOTD(context context.Context, message string) (string, error)
- func (c *MCRPCClient) SetMaxPlayers(context context.Context, max int) (int, error)
- func (c *MCRPCClient) SetOperatorPermissionLevel(context context.Context, level int) (int, error)
- func (c *MCRPCClient) SetOperators(context context.Context, operators []Operator) ([]Operator, error)
- func (c *MCRPCClient) SetPauseWhenEmptySeconds(context context.Context, seconds int) (int, error)
- func (c *MCRPCClient) SetPlayerIdleTimeout(context context.Context, seconds int) (int, error)
- func (c *MCRPCClient) SetSimulationDistance(context context.Context, distance int) (int, error)
- func (c *MCRPCClient) SetSpawnProtectionRadius(context context.Context, radius int) (int, error)
- func (c *MCRPCClient) SetStatusHeartbeatInterval(context context.Context, seconds int) (int, error)
- func (c *MCRPCClient) SetStatusReplies(context context.Context, enable bool) (bool, error)
- func (c *MCRPCClient) SetUseAllowlist(context context.Context, use bool) (bool, error)
- func (c *MCRPCClient) SetViewDistance(context context.Context, distance int) (int, error)
- func (c *MCRPCClient) StopServer(context context.Context) (bool, error)
- func (c *MCRPCClient) UpdateGameRule(context context.Context, gamerule types.UntypedGameRule) (TypedGameRule, error)
- type Operator
- type Player
- type ServerState
- type TypedGameRule
- type UserBan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 MCRPCClient ¶
type MCRPCClient struct {
// JSONRPCConn is the underlying JSON-RPC 2.0 connection.
JSONRPCConn *jsonrpc2.Conn
// WebsocketConn is the underlying WebSocket connection.
WebsocketConn *websocket.Conn
// OnNotification is called for all notifications when no specific handler is set.
OnNotification func(method string, params json.RawMessage)
// Server notification handlers
OnServerStarted func()
OnServerStopping func()
OnServerSaving func()
OnServerSaved func()
OnServerStatus func(status ServerState)
OnServerActivity func()
// Player notification handlers
OnPlayerJoined func(player Player)
OnPlayerLeft func(player Player)
// Operator notification handlers
OnOperatorAdded func(operator Operator)
OnOperatorRemoved func(operator Operator)
// Allowlist notification handlers
OnAllowlistAdded func(player Player)
OnAllowlistRemoved func(player Player)
// Ban notification handlers
OnBanAdded func(ban UserBan)
OnBanRemoved func(player Player)
// IP Ban notification handlers
OnIPBanAdded func(ban IPBan)
OnIPBanRemoved func(ip string)
// Gamerule notification handlers
OnGameruleUpdated func(gamerule TypedGameRule)
// contains filtered or unexported fields
}
MCRPCClient is a client for connecting to and managing Minecraft servers via JSON-RPC 2.0 over WebSocket. It provides methods for server management, player management, and real-time notifications.
func Create ¶
Create establishes a WebSocket connection to the Minecraft server without TLS. The secret is used for authentication with the server.
func CreateWithTLS ¶
func CreateWithTLS(context context.Context, host string, port int, secret string, cert *tls.Certificate, insecure bool) (*MCRPCClient, error)
CreateWithTLS establishes a WebSocket connection to the Minecraft server with TLS. The cert parameter is used for client certificate authentication. If insecure is true, the server's certificate will not be verified.
func (*MCRPCClient) AddAllowlist ¶
AddAllowlist adds the specified players to the allowlist.
func (*MCRPCClient) AddBanlist ¶
AddBanlist adds the specified bans to the ban list.
func (*MCRPCClient) AddIPBanlist ¶
func (c *MCRPCClient) AddIPBanlist(context context.Context, add []IncomingIPBan) ([]IPBan, error)
AddIPBanlist adds the specified IP bans to the ban list.
func (*MCRPCClient) AddOperators ¶
AddOperators adds the specified players as operators.
func (*MCRPCClient) ClearAllowlist ¶
func (c *MCRPCClient) ClearAllowlist(context context.Context) ([]Player, error)
ClearAllowlist removes all players from the allowlist.
func (*MCRPCClient) ClearBanlist ¶
func (c *MCRPCClient) ClearBanlist(context context.Context) ([]UserBan, error)
ClearBanlist removes all bans from the ban list.
func (*MCRPCClient) ClearIPBanlist ¶
func (c *MCRPCClient) ClearIPBanlist(context context.Context) ([]IPBan, error)
ClearIPBanlist removes all IP bans from the ban list.
func (*MCRPCClient) ClearOperators ¶
func (c *MCRPCClient) ClearOperators(context context.Context) ([]Operator, error)
ClearOperators removes all players from the operator list.
func (*MCRPCClient) Close ¶
func (c *MCRPCClient) Close() error
Close closes the WebSocket connection and the underlying JSON-RPC connection. It is safe to call Close multiple times.
func (*MCRPCClient) DisconnectNotify ¶
func (c *MCRPCClient) DisconnectNotify() <-chan struct{}
DisconnectNotify returns a channel that is closed when the connection is closed.
func (*MCRPCClient) GetAcceptTransfers ¶
func (c *MCRPCClient) GetAcceptTransfers(context context.Context) (bool, error)
GetAcceptTransfers retrieves whether the server accepts player transfers.
func (*MCRPCClient) GetAllowFlight ¶
func (c *MCRPCClient) GetAllowFlight(context context.Context) (bool, error)
GetAllowFlight retrieves whether flight is allowed in Survival mode.
func (*MCRPCClient) GetAllowlist ¶
func (c *MCRPCClient) GetAllowlist(context context.Context) ([]Player, error)
GetAllowlist retrieves the current allowlist of players.
func (*MCRPCClient) GetAutosaveEnabled ¶
func (c *MCRPCClient) GetAutosaveEnabled(context context.Context) (bool, error)
GetAutosaveEnabled retrieves whether automatic world saving is enabled.
func (*MCRPCClient) GetBanlist ¶
func (c *MCRPCClient) GetBanlist(context context.Context) ([]UserBan, error)
GetBanlist retrieves the current list of banned players.
func (*MCRPCClient) GetDifficulty ¶
func (c *MCRPCClient) GetDifficulty(context context.Context) (string, error)
GetDifficulty retrieves the current difficulty level of the server.
func (*MCRPCClient) GetEnforceAllowlist ¶
func (c *MCRPCClient) GetEnforceAllowlist(context context.Context) (bool, error)
GetEnforceAllowlist retrieves whether allowlist enforcement is enabled.
func (*MCRPCClient) GetEntityBroadcastRange ¶
func (c *MCRPCClient) GetEntityBroadcastRange(context context.Context) (int, error)
GetEntityBroadcastRange retrieves the entity broadcast range percentage.
func (*MCRPCClient) GetForceGameMode ¶
func (c *MCRPCClient) GetForceGameMode(context context.Context) (bool, error)
GetForceGameMode retrieves whether players are forced to use the default game mode.
func (*MCRPCClient) GetGameMode ¶
func (c *MCRPCClient) GetGameMode(context context.Context) (string, error)
GetGameMode retrieves the server's default game mode.
func (*MCRPCClient) GetGameRules ¶
func (c *MCRPCClient) GetGameRules(context context.Context) ([]TypedGameRule, error)
GetGameRules retrieves all game rules and their current values.
func (*MCRPCClient) GetHideOnlinePlayers ¶
func (c *MCRPCClient) GetHideOnlinePlayers(context context.Context) (bool, error)
GetHideOnlinePlayers retrieves whether online player info is hidden from status queries.
func (*MCRPCClient) GetIPBanlist ¶
func (c *MCRPCClient) GetIPBanlist(context context.Context) ([]IPBan, error)
GetIPBanlist retrieves the current list of banned IP addresses.
func (*MCRPCClient) GetMOTD ¶
func (c *MCRPCClient) GetMOTD(context context.Context) (string, error)
GetMOTD retrieves the server's message of the day.
func (*MCRPCClient) GetMaxPlayers ¶
func (c *MCRPCClient) GetMaxPlayers(context context.Context) (int, error)
GetMaxPlayers retrieves the maximum number of players allowed on the server.
func (*MCRPCClient) GetOperatorPermissionLevel ¶
func (c *MCRPCClient) GetOperatorPermissionLevel(context context.Context) (int, error)
GetOperatorPermissionLevel retrieves the operator permission level.
func (*MCRPCClient) GetOperators ¶
func (c *MCRPCClient) GetOperators(context context.Context) ([]Operator, error)
GetOperators retrieves the current list of operators.
func (*MCRPCClient) GetPauseWhenEmptySeconds ¶
func (c *MCRPCClient) GetPauseWhenEmptySeconds(context context.Context) (int, error)
GetPauseWhenEmptySeconds retrieves the pause when empty timeout in seconds.
func (*MCRPCClient) GetPlayerIdleTimeout ¶
func (c *MCRPCClient) GetPlayerIdleTimeout(context context.Context) (int, error)
GetPlayerIdleTimeout retrieves the player idle timeout in seconds.
func (*MCRPCClient) GetPlayers ¶
func (c *MCRPCClient) GetPlayers(context context.Context) ([]Player, error)
GetPlayers retrieves the list of currently online players.
func (*MCRPCClient) GetServerStatus ¶
func (c *MCRPCClient) GetServerStatus(context context.Context) (ServerState, error)
GetServerStatus retrieves the current status of the server including online players and version information.
func (*MCRPCClient) GetSimulationDistance ¶
func (c *MCRPCClient) GetSimulationDistance(context context.Context) (int, error)
GetSimulationDistance retrieves the simulation distance in chunks.
func (*MCRPCClient) GetSpawnProtectionRadius ¶
func (c *MCRPCClient) GetSpawnProtectionRadius(context context.Context) (int, error)
GetSpawnProtectionRadius retrieves the spawn protection radius in blocks.
func (*MCRPCClient) GetStatusHeartbeatInterval ¶
func (c *MCRPCClient) GetStatusHeartbeatInterval(context context.Context) (int, error)
GetStatusHeartbeatInterval retrieves the status heartbeat interval in seconds.
func (*MCRPCClient) GetStatusReplies ¶
func (c *MCRPCClient) GetStatusReplies(context context.Context) (bool, error)
GetStatusReplies retrieves whether the server responds to status requests.
func (*MCRPCClient) GetUseAllowlist ¶
func (c *MCRPCClient) GetUseAllowlist(context context.Context) (bool, error)
GetUseAllowlist retrieves whether the allowlist is enabled.
func (*MCRPCClient) GetViewDistance ¶
func (c *MCRPCClient) GetViewDistance(context context.Context) (int, error)
GetViewDistance retrieves the view distance in chunks.
func (*MCRPCClient) IsClosed ¶
func (c *MCRPCClient) IsClosed() bool
IsClosed returns true if the connection has been closed.
func (*MCRPCClient) KickPlayers ¶
func (c *MCRPCClient) KickPlayers(context context.Context, kick []KickPlayer) ([]Player, error)
KickPlayers kicks the specified players from the server with custom messages.
func (*MCRPCClient) RemoveAllowlist ¶
RemoveAllowlist removes the specified players from the allowlist.
func (*MCRPCClient) RemoveBanlist ¶
RemoveBanlist removes the specified players from the ban list.
func (*MCRPCClient) RemoveIPBanlist ¶
RemoveIPBanlist removes the specified IP addresses from the ban list.
func (*MCRPCClient) RemoveOperators ¶
RemoveOperators removes the specified players from the operator list.
func (*MCRPCClient) SaveServer ¶
SaveServer saves the current server state. If flush is true, all pending changes are flushed to disk.
func (*MCRPCClient) SendSystemMessage ¶
func (c *MCRPCClient) SendSystemMessage(context context.Context, message types.SystemMessage) (bool, error)
SendSystemMessage sends a system message to the specified players on the server.
func (*MCRPCClient) SetAcceptTransfers ¶
SetAcceptTransfers sets whether the server accepts player transfers.
func (*MCRPCClient) SetAllowFlight ¶
SetAllowFlight sets whether flight is allowed in Survival mode.
func (*MCRPCClient) SetAllowlist ¶
SetAllowlist sets the allowlist to the specified list of players, replacing the existing list.
func (*MCRPCClient) SetAutosaveEnabled ¶
SetAutosaveEnabled enables or disables automatic world saving.
func (*MCRPCClient) SetBanlist ¶
SetBanlist sets the ban list to the specified list of bans, replacing the existing list.
func (*MCRPCClient) SetDifficulty ¶
SetDifficulty sets the difficulty level of the server (peaceful, easy, normal, hard).
func (*MCRPCClient) SetEnforceAllowlist ¶
SetEnforceAllowlist enables or disables allowlist enforcement.
func (*MCRPCClient) SetEntityBroadcastRange ¶
func (c *MCRPCClient) SetEntityBroadcastRange(context context.Context, percentagePoints int) (int, error)
SetEntityBroadcastRange sets the entity broadcast range percentage.
func (*MCRPCClient) SetForceGameMode ¶
SetForceGameMode sets whether players are forced to use the default game mode.
func (*MCRPCClient) SetGameMode ¶
SetGameMode sets the server's default game mode (creative, survival, spectator, adventure).
func (*MCRPCClient) SetHideOnlinePlayers ¶
SetHideOnlinePlayers sets whether online player info is hidden from status queries.
func (*MCRPCClient) SetIPBanlist ¶
SetIPBanlist sets the IP ban list to the specified list, replacing the existing list.
func (*MCRPCClient) SetMaxPlayers ¶
SetMaxPlayers sets the maximum number of players allowed on the server.
func (*MCRPCClient) SetOperatorPermissionLevel ¶
SetOperatorPermissionLevel sets the operator permission level.
func (*MCRPCClient) SetOperators ¶
func (c *MCRPCClient) SetOperators(context context.Context, operators []Operator) ([]Operator, error)
SetOperators sets the operator list to the specified list, replacing the existing list.
func (*MCRPCClient) SetPauseWhenEmptySeconds ¶
SetPauseWhenEmptySeconds sets the pause when empty timeout in seconds.
func (*MCRPCClient) SetPlayerIdleTimeout ¶
SetPlayerIdleTimeout sets the player idle timeout in seconds.
func (*MCRPCClient) SetSimulationDistance ¶
SetSimulationDistance sets the simulation distance in chunks.
func (*MCRPCClient) SetSpawnProtectionRadius ¶
SetSpawnProtectionRadius sets the spawn protection radius in blocks.
func (*MCRPCClient) SetStatusHeartbeatInterval ¶
SetStatusHeartbeatInterval sets the status heartbeat interval in seconds.
func (*MCRPCClient) SetStatusReplies ¶
SetStatusReplies sets whether the server responds to status requests.
func (*MCRPCClient) SetUseAllowlist ¶
SetUseAllowlist enables or disables the allowlist.
func (*MCRPCClient) SetViewDistance ¶
SetViewDistance sets the view distance in chunks.
func (*MCRPCClient) StopServer ¶
func (c *MCRPCClient) StopServer(context context.Context) (bool, error)
StopServer stops the Minecraft server.
func (*MCRPCClient) UpdateGameRule ¶
func (c *MCRPCClient) UpdateGameRule(context context.Context, gamerule types.UntypedGameRule) (TypedGameRule, error)
UpdateGameRule updates the value of a specific game rule.
type ServerState ¶
type ServerState = types.ServerState
ServerState is an alias for types.ServerState, representing the current state of the server.
type TypedGameRule ¶
type TypedGameRule = types.TypedGameRule
TypedGameRule is an alias for types.TypedGameRule, representing a game rule with a typed 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. |