Interface MachinePlayer
@NonExtendable
public interface MachinePlayer
Everything MachineEngine and its addons keep for one player (D37): values of registered
PlayerDataKeys and PlayerSettings. Get it with MachineEngine.get().players().get(player).
Use it on the player's own thread (their entity scheduler on Folia), like a machine on its region. Reads and writes are safe from any thread, but two threads updating the same value race.
-
Method Summary
Modifier and TypeMethodDescription<T> Tget(@NotNull PlayerDataKey<T> key) <T> Tget(@NotNull PlayerSetting<T> setting) The setting's value: the server owner's value if they locked it, else the player's choice, else the server owner's default, else the setting's own default.@Nullable org.bukkit.entity.Playerplayer()The online player;nullfor data loaded for an offline player (MachinePlayers.loadOffline(UUID)).voidreset(@NotNull PlayerDataKey<?> key) Back to the key's default (removed from the saved data).<T> voidset(@NotNull PlayerDataKey<T> key, T value) <T> @NotNull Result<T> set(@NotNull PlayerSetting<T> setting, @NotNull String text) Changes a setting from what the player typed.@NotNull Set<net.kyori.adventure.key.Key> Saved values whose key is not registered (their addon is missing); kept and saved again (D3).<T> Tupdate(@NotNull PlayerDataKey<T> key, @NotNull UnaryOperator<T> change) Sets the value tochangeof the current one, atomically, and returns it.@NotNull UUIDuuid()
-
Method Details
-
uuid
-
player
@Nullable @Nullable org.bukkit.entity.Player player()The online player;nullfor data loaded for an offline player (MachinePlayers.loadOffline(UUID)). -
get
- Returns:
- the value, or the key's default if none was set
- Throws:
IllegalArgumentException- ifkeyis not registered
-
set
- Throws:
IllegalArgumentException- ifkeyis not registered
-
update
@NotNull <T> T update(@NotNull @NotNull PlayerDataKey<T> key, @NotNull @NotNull UnaryOperator<T> change) Sets the value tochangeof the current one, atomically, and returns it. -
reset
Back to the key's default (removed from the saved data). -
get
The setting's value: the server owner's value if they locked it, else the player's choice, else the server owner's default, else the setting's own default. -
set
@NotNull <T> @NotNull Result<T> set(@NotNull @NotNull PlayerSetting<T> setting, @NotNull @NotNull String text) Changes a setting from what the player typed.- Returns:
- the new value, or an error when
textis not valid or the setting is locked
-
unknownKeys
Saved values whose key is not registered (their addon is missing); kept and saved again (D3).
-