Skip to main content
The Player interface represents a connected Minecraft player on the proxy. It provides methods for communication, server switching, resource packs, and more.

Overview

The Player interface extends multiple interfaces:
  • Inbound - Connection information
  • netmc.PacketWriter - Packet sending capabilities
  • command.Source - Command execution source
  • message.ChannelMessageSource - Plugin message source
  • message.ChannelMessageSink - Plugin message sink
  • crypto.KeyIdentifiable - Player key identification
Source: pkg/edition/java/proxy/player.go:52

Getting Players

Retrieve player instances from the proxy:

Player Information

Basic Properties

Access player identity and status:
uuid.UUID
The player’s Minecraft UUID.
string
The player’s Minecraft username.
time.Duration
Returns the player’s ping, or -1 if currently unknown.
bool
Returns true if the player was authenticated with Mojang’s session servers.

Client Information

Get information about the player’s client:
player.Settings
Returns the player’s client settings, or player.DefaultSettings if unknown.
string
Returns the client brand, or empty string if unspecified.

Messaging

Sending Chat Messages

Send messages to the player:
component.Component
required
The message component to send. Nil messages are ignored.
...command.MessageOption
Optional message options like type and sender.

Message Types

Available message types:

Action Bar

Send action bar messages:
component.Component
required
The action bar message component. Nil messages are ignored.

Spoofing Chat Input

Send chat input as if the player typed it:
string
required
The chat input to spoof. Maximum 256 characters.
error
Returns ErrTooLongChatMessage if input exceeds 256 characters, or ErrNoBackendConnection if player is not connected to a server.

Server Connection

Current Server

Get the player’s current server:
ServerConnection
Returns the current server connection, or nil if not connected to any backend server.

Switching Servers

Connect the player to a different server:
RegisteredServer
required
The target server to connect to.
ConnectionRequest
A connection request builder for switching servers.

Resource Packs

Sending Resource Packs

Send a resource pack to the player:
ResourcePackInfo
required
Resource pack information including URL, hash, prompt, and whether it’s required.
error
Returns an error if the pack is already applied or if sending fails.

Tracking Resource Pack Status

Get applied and pending resource packs:
[]*ResourcePackInfo
All resource packs that were applied and accepted by the player.
[]*ResourcePackInfo
All resource packs currently being sent to the player.

Tab List

Manage the player’s tab list:
tablist.TabList
The player’s tab list for modification.

Plugin Messages

Send plugin messages to the player’s client:
message.ChannelIdentifier
required
The plugin message channel identifier.
[]byte
required
The message data to send.
This sends the message to the player’s client, not to their current server. To send a message to the server, use player.CurrentServer().SendPluginMessage().

Player Transfer

Transfer the player to another server (1.20.5+):
string
required
The target address in format “host:port” or just “host” (defaults to port 25565).
error
Returns ErrTransferUnsupportedClientProtocol if player’s client version is below 1.20.5.

Disconnection

Disconnect the player from the proxy:
component.Component
required
The disconnect reason to display to the player.
Once Disconnect() is called, further interface calls to this player become undefined.

Player Context

Get the player’s context for managing operations:
context.Context
A context that is cancelled when the player’s connection is closed.

Complete Example

See Also