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 Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Builds the storage when MachineEngine enables.
    static final record 
    A storage registered under a key, for players.storage.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Waits for every pending save; called when MachineEngine stops.
    load(@NotNull UUID uuid, @Nullable org.bukkit.entity.Player online)
    The saved data of a player, DataMap.EMPTY if there is none.
    default boolean
    Whether loading and saving need the online player (and so cannot serve offline players).
    save(@NotNull UUID uuid, @Nullable org.bukkit.entity.Player online, @NotNull DataMap data)
    Saves the data of a player; called on the player's thread when online is 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.EMPTY if there is none. Called in the AsyncPlayerPreLoginEvent (off the main thread, online null) unless needsOnlinePlayer(), then in the PlayerJoinEvent on 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 when online is 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.