Packages com.phoenixplugins.phoenixcrates.api player

Interface PlayerDataLayer


public interface PlayerDataLayer
Represents a data layer that can decide whether to return its own cached data or fetch from the next layer (typically database).

This follows the Chain of Responsibility pattern, allowing layers to be composed. Each layer can intercept data operations and either return cached data or delegate to the next layer in the chain.

  • Method Details

    • fetchByUniqueId

      CompletableFuture<? extends PlayerDbModel> fetchByUniqueId(UUID uniqueId)
      Fetches player data by unique ID.

      The layer decides whether to return cached data or fetch from the next layer.

      Parameters:
      uniqueId - the player's unique ID
      Returns:
      a future completing with the player's database model, or null if not found
    • insert

      <T extends PlayerDbModel> CompletableFuture<T> insert(T model)
      Inserts new player data.

      The layer can cache the data after the insert operation completes.

      Type Parameters:
      T - the concrete player database model type
      Parameters:
      model - the player database model to insert
      Returns:
      a future completing with the inserted model (with generated ID)
    • update

      <T extends PlayerDbModel> CompletableFuture<Void> update(T model)
      Updates player data.

      The layer can update its cache before passing the update to the next layer.

      Type Parameters:
      T - the concrete player database model type
      Parameters:
      model - the player database model to update
      Returns:
      a future completing when the update operation is done
    • setNextLayer

      void setNextLayer(PlayerDataLayer nextLayer)
      Sets the next layer in the chain.

      This allows layers to be composed in a chain of responsibility pattern.

      Parameters:
      nextLayer - the next layer to delegate to, or null to remove the chain
    • getNextLayer

      PlayerDataLayer getNextLayer()
      Gets the next layer in the chain.
      Returns:
      the next layer, or null if this is the last layer
    • dispose

      default CompletableFuture<Void> dispose(UUID uniqueId, PlayerDbModel model, boolean isDirty)
      Handles disposal of player data.

      This is called when player data is being unloaded from memory. The layer should release any locks and update Redis if the data is dirty.

      Parameters:
      uniqueId - the player's unique ID
      model - the player database model (may be null)
      isDirty - whether the data is dirty and needs to be saved
      Returns:
      a future completing when the disposal operation is done
Last updated 10 days ago
My Cart
Spider

Your cart is empty

Looks like the spiders padded through here. Pick a plugin and it will show up here. Continue shopping