Contents
Interface PlayerStorage
- All Known Implementing Classes:
DiskPlayerStorageProvider.DiskPlayerStorage
public interface PlayerStorage
An interface that represents a strategy for storing and retrieving player data.
-
Method Summary
Modifier and TypeMethodDescriptionGets a set of all player UUIDs stored in this PlayerStorage.Loads the player data for the given UUID.Removes the player data for the given UUID.save(UUID uuid, Holder<EntityStore> holder, boolean required) Saves the player data for the given UUID.update(UUID uuid, Consumer<Holder<EntityStore>> modifier) Atomically loads player data, applies a modification, and saves it back.
-
Method Details
-
load
Loads the player data for the given UUID.- Parameters:
uuid- TheUUIDof the player to load.- Returns:
- a
CompletableFuturethat will be completed with aHoldercontaining theEntityStore.
-
save
@Nonnull CompletableFuture<Void> save(@Nonnull UUID uuid, @Nonnull Holder<EntityStore> holder, boolean required) Saves the player data for the given UUID.- Parameters:
uuid- TheUUIDof the player to save.holder- AHoldercontaining theEntityStoreto save.required- Whether the save should be forced or not- Returns:
- a
CompletableFuturethat 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- TheUUIDof the player to update.modifier- A consumer that modifies the loadedHolder.- Returns:
- a
CompletableFuturethat will be completed when the update is done.
-
remove
Removes the player data for the given UUID.- Parameters:
uuid- TheUUIDof the player to remove.- Returns:
- a
CompletableFuturethat will be completed when the remove operation is done.
-
getPlayers
Gets a set of all player UUIDs stored in this PlayerStorage.- Returns:
- a
SetofUUIDs representing all stored players. - Throws:
IOException- if an I/O error occurs while retrieving the player UUIDs.
-