Class PlayerConnection
java.lang.Object
net.minestom.server.network.player.PlayerConnection
- Direct Known Subclasses:
PlayerSocketConnection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidForcing the player to disconnect.CompletableFuture<byte @Nullable []> fetchCookie(String key) Deprecated, for removal: This API element is subject to removal in a future version.Returns a printable identifier for this connection, will be the player username or the connection remote address.Gets the player linked to this connection.intGets protocol version of client.abstract SocketAddressGets the remote address of the client.Gets the server address that the client used to connect.intGets the server port that the client used to connect.booleanisOnline()Gets if the client is still connected to the server.voidKicks the player with a reason.Gets the login plugin message processor, only available during the login state.voidreceiveCookieResponse(String key, byte @Nullable [] data) voidreceiveKnownPacksResponse(List<SelectKnownPacksPacket.Entry> clientPacks) requestKnownPacks(List<SelectKnownPacksPacket.Entry> serverPacks) abstract voidsendPacket(SendablePacket packet) Serializes the packet and send it to the client.voidsendPackets(Collection<SendablePacket> packets) voidsendPackets(SendablePacket... packets) voidsetClientState(ConnectionState clientState) voidChanges the player linked to this connection.voidsetPlayerPublicKey(PlayerPublicKey playerPublicKey) voidsetServerState(ConnectionState serverState) voidstoreCookie(String key, byte[] data) toString()
-
Constructor Details
-
PlayerConnection
public PlayerConnection()
-
-
Method Details
-
getIdentifier
Returns a printable identifier for this connection, will be the player username or the connection remote address.- Returns:
- this connection identifier
-
sendPacket
Serializes the packet and send it to the client.- Parameters:
packet- the packet to send
-
sendPackets
-
sendPackets
-
getRemoteAddress
Gets the remote address of the client.- Returns:
- the remote address
-
getProtocolVersion
public int getProtocolVersion()Gets protocol version of client.- Returns:
- the protocol version
-
getServerAddress
-
getServerPort
public int getServerPort()Gets the server port that the client used to connect.WARNING: it is given by the client, it is possible for it to be wrong.
- Returns:
- the server port used
-
kick
Kicks the player with a reason.- Parameters:
component- the reason
-
disconnect
public void disconnect()Forcing the player to disconnect. -
getPlayer
-
setPlayer
Changes the player linked to this connection.WARNING: unsafe.
- Parameters:
player- the player
-
isOnline
public boolean isOnline()Gets if the client is still connected to the server.- Returns:
- true if the player is online, false otherwise
-
getConnectionState
Deprecated, for removal: This API element is subject to removal in a future version.UsegetClientState()orgetServerState()instead. -
getServerState
-
getClientState
-
setClientState
-
setServerState
-
playerPublicKey
-
setPlayerPublicKey
-
storeCookie
-
fetchCookie
-
receiveCookieResponse
-
loginPluginMessageProcessor
Gets the login plugin message processor, only available during the login state. -
requestKnownPacks
@Internal public CompletableFuture<List<SelectKnownPacksPacket.Entry>> requestKnownPacks(List<SelectKnownPacksPacket.Entry> serverPacks) -
receiveKnownPacksResponse
-
toString
-
getClientState()orgetServerState()instead.