Interface PlayerDataStorage
public interface PlayerDataStorage
Where the persistent values of players are saved (D37). MachineEngine ships
machineengine:pdc
(the player's PersistentDataContainer, the default) and machineengine:files (one file
per player); an addon adds another with RegistrationContext#playerStorages(), and the server
owner picks one with players.storage in MachineEngine's config.yml.
A storage gets and returns the whole saved data of a player as a DataMap; DataBinary
turns it into bytes. MachineEngine never asks for the same player's load and save at once, and calls
save(UUID, Player, DataMap) in order for one player.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceBuilds the storage when MachineEngine enables.static final recordA storage registered under a key, forplayers.storage. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Waits for every pending save; called when MachineEngine stops.@NotNull CompletableFuture<DataMap> The saved data of a player,DataMap.EMPTYif there is none.default booleanWhether loading and saving need the online player (and so cannot serve offline players).@NotNull CompletableFuture<Void> Saves the data of a player; called on the player's thread whenonlineis not null.
-
Method Details
-
load
@NotNull @NotNull CompletableFuture<DataMap> load(@NotNull @NotNull UUID uuid, @Nullable @Nullable org.bukkit.entity.Player online) The saved data of a player,DataMap.EMPTYif there is none. Called in theAsyncPlayerPreLoginEvent(off the main thread,onlinenull) unlessneedsOnlinePlayer(), then in thePlayerJoinEventon the player's thread. -
save
@NotNull @NotNull CompletableFuture<Void> save(@NotNull @NotNull UUID uuid, @Nullable @Nullable org.bukkit.entity.Player online, @NotNull @NotNull DataMap data) Saves the data of a player; called on the player's thread whenonlineis not null. -
needsOnlinePlayer
default boolean needsOnlinePlayer()Whether loading and saving need the online player (and so cannot serve offline players). -
close
default void close()Waits for every pending save; called when MachineEngine stops.
-