Interface Player
- All Superinterfaces:
CommandSource, PermissionSubject
Represents a player connected to the proxy.
Players are command sources and permission subjects, meaning they can execute commands
and be checked for permissions using PermissionSubject.hasPermission(String) or PermissionSubject.getPermissionValue(String).
Since Player extends CommandSource, players can be used anywhere
a command source is expected.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(String reason) Disconnect the player with a reason.Get the server the player is currently connected to.longgetPing()Get the player's ping/latency in milliseconds.Get the player's settings/preferences.Get the protocol hash the player is using.Get the player's remote address.longGet the session ID for this player's connection.Get the player's UUID.Get the player's username.booleanCheck if the player is currently connected.voidsendMessage(String message) Send a chat message to the player.voidsendMessage(ChatMessageBuilder builder) Send a formatted chat message to the player.voidsendPacket(Object packet) Send a packet to the player's client.voidsendPacketToServer(Object packet) Send a packet to the backend server on behalf of this player.Transfer the player to a different backend server by name.transfer(RegisteredServer server) Transfer the player to a different backend server.Methods inherited from interface CommandSource
asPlayer, isConsole, isPlayerMethods inherited from interface PermissionSubject
getPermissionFunction, getPermissionValue, hasPermission, setPermissionFunction
-
Method Details
-
getUniqueId
-
getUsername
-
getRemoteAddress
Get the player's remote address.- Returns:
- the address the player connected from
-
getCurrentServer
Get the server the player is currently connected to.- Returns:
- the current server, or empty if not connected to any backend
-
isConnected
boolean isConnected()Check if the player is currently connected.- Returns:
- true if connected
-
getPing
long getPing()Get the player's ping/latency in milliseconds.- Returns:
- the ping in milliseconds, or -1 if unknown
-
sendPacket
Send a packet to the player's client.- Parameters:
packet- the packet to send
-
sendPacketToServer
Send a packet to the backend server on behalf of this player.- Parameters:
packet- the packet to send
-
sendMessage
Send a chat message to the player.- Specified by:
sendMessagein interfaceCommandSource- Parameters:
message- the message to send
-
sendMessage
Send a formatted chat message to the player.Example usage:
player.sendMessage(ChatMessageBuilder.create() .green("[Success] ") .white("Operation completed!"));- Specified by:
sendMessagein interfaceCommandSource- Parameters:
builder- the ChatMessageBuilder with the formatted message
-
disconnect
Disconnect the player with a reason.- Parameters:
reason- the disconnect reason to show the player
-
transfer
Transfer the player to a different backend server.- Parameters:
server- the server to transfer to- Returns:
- a future that completes when the transfer is initiated
-
transfer
Transfer the player to a different backend server by name.- Parameters:
serverName- the name of the server to transfer to- Returns:
- a future that completes when the transfer is initiated
-
getProtocolHash
Get the protocol hash the player is using.- Returns:
- the protocol hash, or null if unknown
-
getSessionId
long getSessionId()Get the session ID for this player's connection.- Returns:
- the internal session ID
-
getPlayerSettings
Get the player's settings/preferences.Settings include locale, client type, and other information extracted from the Connect packet.
Example usage:
Locale locale = player.getPlayerSettings().getLocale(); String localizedMessage = getTranslation("welcome.message", locale); player.sendMessage(localizedMessage);- Returns:
- the player's settings
-