Interface Player<C>
-
Method Summary
Modifier and TypeMethodDescription@Nullable StringRetrieves the client brand name associated with the player.@NotNull StringRetrieves the host address to which the player is connected.@NotNull LocaleRetrieves the locale associated with the player.@Nullable LocationRetrieves the location associated with the player.longgetPing()Retrieves the latency or ping value for the player in milliseconds.static @Nullable Player<?>static @Nullable Player<?>default intRetrieves the protocol version of the player.default @NotNull one.tranic.t.utils.minecraft.ProtocolVersionRetrieves the protocol version of the player.Retrieves the underlying source object associated with this player.@NotNull UUIDRetrieves the unique identifier (UUID) of the player.@NotNull StringRetrieves the username of the player.default booleanDetermines whether the player associated with this instance is a Bedrock player.booleanisOnline()Checks whether the player is currently online.booleankick()Removes the player from the server or disconnects the player for an unspecified reason.booleankick(@NotNull net.kyori.adventure.text.Component reason) Disconnects the player from the server with the specified reason.booleanKicks the player from the game or server with a specified reason.voidsendMessage(@NotNull String message) Sends a text message to the player.voidsendMessage(@NotNull net.kyori.adventure.text.Component message) Sends a message to the player represented by this instance.default @Nullable BedrockPlayerConverts the current player instance to a BedrockPlayer.
-
Method Details
-
getPlayer
-
getPlayer
-
toBedrockPlayer
Converts the current player instance to a BedrockPlayer.- Returns:
- a
BedrockPlayerinstance if the player is a Bedrock player, or null if not applicable
-
getUsername
Retrieves the username of the player.- Returns:
- the username of the player as a string
-
getUniqueId
Retrieves the unique identifier (UUID) of the player.- Returns:
- the universally unique identifier (UUID) of the player
-
getPlayerProtocolVersion
default int getPlayerProtocolVersion()Retrieves the protocol version of the player.For Bedrock players, the method returns -1 as they do not use protocol versions.
For non-Bedrock players, the method fetches their protocol version using ViaPlayer.
- Returns:
- the protocol version of the player as an integer, or -1 if the player is a Bedrock player
-
getPlayerVersion
@NotNull default @NotNull one.tranic.t.utils.minecraft.ProtocolVersion getPlayerVersion()Retrieves the protocol version of the player.This method determines the player's protocol version based on:
- If the player is a Bedrock player, the protocol version will be
ProtocolVersion.UNKNOWN.- Otherwise, it uses the
ViaPlayer.getVersion(UUID)implementation to fetch the protocol version based on the player's unique identifier (UUID).- Returns:
- the player's protocol version as a
ProtocolVersioninstance.
-
getConnectedHost
Retrieves the host address to which the player is connected.- Returns:
- the connected host as a string.
-
isBedrockPlayer
default boolean isBedrockPlayer()Determines whether the player associated with this instance is a Bedrock player. This method utilizes theBedrockPlayer.isBedrockPlayer(UUID)implementation.- Returns:
- true if the player is a Bedrock player; false otherwise.
-
getLocale
Retrieves the locale associated with the player.- Returns:
- the locale representing the player's language and regional preferences.
-
getLocation
Retrieves the location associated with the player.- Returns:
- the
Locationof the player if available, ornullif the location is not set.
-
getPing
long getPing()Retrieves the latency or ping value for the player in milliseconds.The ping represents the time taken for data packets to travel from the player to the server and back. It serves as a measure of network latency between the player and the server.
- Returns:
- the ping value in milliseconds
-
isOnline
boolean isOnline()Checks whether the player is currently online.- Returns:
- true if the player is online, otherwise false
-
getClientBrand
Retrieves the client brand name associated with the player.The client brand name typically refers to the branding or specific modification of the client being used by the player (e.g., "vanilla" or a modified client). This method may return null if the client brand is not available or not applicable for the player.
- Returns:
- the client brand name as a string, or null if not available.
-
getSourcePlayer
Retrieves the underlying source object associated with this player.- Returns:
- the source player object of type C
-
kick
boolean kick()Removes the player from the server or disconnects the player for an unspecified reason.- Returns:
- true if the player was successfully kicked, false otherwise
-
kick
Kicks the player from the game or server with a specified reason.- Parameters:
reason- the message or reason for the kick- Returns:
- true if the player was successfully kicked, false otherwise
-
kick
boolean kick(@NotNull @NotNull net.kyori.adventure.text.Component reason) Disconnects the player from the server with the specified reason.- Parameters:
reason- the reason for disconnecting the player; must not be null- Returns:
- true if the player was successfully disconnected, false otherwise
-
sendMessage
Sends a text message to the player.- Parameters:
message- the message to be sent, must not be null
-
sendMessage
void sendMessage(@NotNull @NotNull net.kyori.adventure.text.Component message) Sends a message to the player represented by this instance.- Parameters:
message- the message to be sent; must not be null
-