Class Player
java.lang.Object
de.rexlcloud.core.api.Player
- All Implemented Interfaces:
Serializable
A player who is online on the network: on which proxy and server, and since when.
The object is updated by the cloud while the player is online (e.g. getServer() after a server switch).
Actions like connect(String) or sendMessage(Component) are carried out by the player's proxy.
Players can also have data that plugins store for them in the cloud's database (setData(String, T)); it stays when
they leave and is available on every server.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPlayer(@NonNull String name, @NotNull UUID uuid, @NonNull Server server, @NonNull Server proxyServer, long login, ArrayList<PlayerDatabaseData> data) Internal: players come fromRexlCloudApi. -
Method Summary
Modifier and TypeMethodDescriptionSends the player to another server.Sends the player to another server.connectAndTeleport(@NonNull Server server, @NonNull ServerLocation serverLocation) Sends the player to another server and teleports them there once they arrived.connectAndTeleport(@NonNull String serverName, @NonNull ServerLocation serverLocation) Sends the player to another server and teleports them there once they arrived.Sends the player to a fallback server (a server of a group marked as fallback, e.g.getData()The stored data entries of the player; read them withgetData(String).<T extends Serializable>
Optional<T> Data a plugin stored for this player.longgetLogin()When the player joined the network, in milliseconds since the epoch.@NonNull StringgetName()The player's name.@NonNull ServerThe proxy the player is connected through.@NonNull ServerThe server the player is on.@NotNull UUIDgetUuid()The player's UUID.booleanDisconnects the player from the network.voidremoveData(String key) Removes the player's data under this key from the database.sendMessage(@Nullable String message) Sends a plain text message to the player.sendMessage(@Nullable net.kyori.adventure.text.Component message) Sends a chat message to the player, e.g.<T extends Serializable>
booleanStores data for the player in the cloud's database, replacing a value with the same key.teleport(ServerLocation serverLocation) Teleports the player on the server they are on.protected voidInternal: applies a newer state of the player.protected voidupdateData(String key, byte[] data) Internal: applies data changed on another server.
-
Constructor Details
-
Player
public Player(@NonNull @NonNull String name, @NotNull @NotNull UUID uuid, @NonNull @NonNull Server server, @NonNull @NonNull Server proxyServer, long login, ArrayList<PlayerDatabaseData> data) Internal: players come fromRexlCloudApi.
-
-
Method Details
-
update
-
getData
Data a plugin stored for this player. Only JDK value types and classes of the calling plugin are read; data of other types is treated as missing. -
setData
Stores data for the player in the cloud's database, replacing a value with the same key. The value is serialized with Java serialization; only JDK value types (strings, numbers, collections, time types) and classes of the plugin itself can be read back withgetData(String).- Type Parameters:
T- type of the value- Parameters:
key- name of the value, e.g."coins"value- the value- Returns:
falseif the value could not be serialized
-
hasData
- Parameters:
key- name of a value- Returns:
- whether the player has data under this key
-
removeData
Removes the player's data under this key from the database.- Parameters:
key- name of the value
-
updateData
Internal: applies data changed on another server. -
kick
Disconnects the player from the network.- Parameters:
message- reason shown to the player (MiniMessage or&colour codes),nullfor none- Returns:
- completes once the proxy received the request
-
sendMessage
Sends a plain text message to the player.- Parameters:
message- the text- Returns:
- completes once the proxy received the request
-
sendMessage
public CompletableFuture<Boolean> sendMessage(@Nullable @Nullable net.kyori.adventure.text.Component message) Sends a chat message to the player, e.g. one built with Adventure orCloudText.parse(String).- Parameters:
message- the message- Returns:
- completes once the proxy received the request
-
connect
Sends the player to another server.- Parameters:
server- the target server- Returns:
- completes once the proxy received the request
-
connect
Sends the player to another server.- Parameters:
serverName- name of the target server- Returns:
- completes once the proxy received the request
-
connectToFallbackServer
Sends the player to a fallback server (a server of a group marked as fallback, e.g. a lobby).- Returns:
- completes once the proxy received the request
-
connectAndTeleport
public CompletableFuture<Boolean> connectAndTeleport(@NonNull @NonNull Server server, @NonNull @NonNull ServerLocation serverLocation) Sends the player to another server and teleports them there once they arrived.- Parameters:
server- the target serverserverLocation- where on it- Returns:
- completes once the proxy received the request
-
connectAndTeleport
public CompletableFuture<Boolean> connectAndTeleport(@NonNull @NonNull String serverName, @NonNull @NonNull ServerLocation serverLocation) Sends the player to another server and teleports them there once they arrived.- Parameters:
serverName- name of the target serverserverLocation- where on it- Returns:
- completes once the proxy received the request
-
teleport
Teleports the player on the server they are on.- Parameters:
serverLocation- the target; its world name selects the world- Returns:
- completes once the server received the request
-
getLocation
- Returns:
- where the player is, asked from their server
-
getName
The player's name. -
getUuid
The player's UUID. -
getServer
The server the player is on. -
getProxyServer
The proxy the player is connected through. -
getLogin
public long getLogin()When the player joined the network, in milliseconds since the epoch. -
getData
The stored data entries of the player; read them withgetData(String).
-