Interface PlayerStorage

All Known Implementing Classes:
DiskPlayerStorageProvider.DiskPlayerStorage

public interface PlayerStorage
An interface that represents a strategy for storing and retrieving player data.
  • Method Details

    • load

      @Nonnull CompletableFuture<Holder<EntityStore>> load(@Nonnull UUID uuid)
      Loads the player data for the given UUID.
      Parameters:
      uuid - The UUID of the player to load.
      Returns:
      a CompletableFuture that will be completed with a Holder containing the EntityStore.
    • save

      @Nonnull CompletableFuture<Void> save(@Nonnull UUID uuid, @Nonnull Holder<EntityStore> holder, boolean required)
      Saves the player data for the given UUID.
      Parameters:
      uuid - The UUID of the player to save.
      holder - A Holder containing the EntityStore to save.
      required - Whether the save should be forced or not
      Returns:
      a CompletableFuture that will be completed when the save operation is done.
    • update

      @Nonnull CompletableFuture<Void> update(@Nonnull UUID uuid, @Nonnull Consumer<Holder<EntityStore>> modifier)
      Atomically loads player data, applies a modification, and saves it back.

      The entire load-modify-save is performed as a single storage operation, ensuring proper coordination with backup locking and other concurrent saves.

      Parameters:
      uuid - The UUID of the player to update.
      modifier - A consumer that modifies the loaded Holder.
      Returns:
      a CompletableFuture that will be completed when the update is done.
    • remove

      @Nonnull CompletableFuture<Void> remove(@Nonnull UUID uuid)
      Removes the player data for the given UUID.
      Parameters:
      uuid - The UUID of the player to remove.
      Returns:
      a CompletableFuture that will be completed when the remove operation is done.
    • getPlayers

      @Nonnull Set<UUID> getPlayers() throws IOException
      Gets a set of all player UUIDs stored in this PlayerStorage.
      Returns:
      a Set of UUIDs representing all stored players.
      Throws:
      IOException - if an I/O error occurs while retrieving the player UUIDs.