Interface DataManager


  • public interface DataManager
    The manager for all data related operations.
    • Method Detail

      • reload

        void reload()
        Reloads everything data related.
      • saveDataPool

        int saveDataPool()
        Saves all data to the data pool.
        Returns:
        the amount of data saved
      • shutdown

        void shutdown()
        Saves all data to the data pool and then shuts all data pools down.
      • loadPlayerData

        void loadPlayerData​(UUID uuid)
        Loads the player data from the data source and caches it asynchronously.
        Parameters:
        uuid - the player's UUID
      • unloadPlayerData

        void unloadPlayerData​(UUID uuid)
        Unloads the player data from the cache and saves it to the data source asynchronously.
        Parameters:
        uuid - the player's UUID
      • getPlayerData

        PlayerData getPlayerData​(UUID uuid)
        Gets the player data from the cache.
        Parameters:
        uuid - the player's UUID
        Returns:
        the found PlayerData or a new instance if not found
      • addVirtualKeys

        CompletableFuture<Boolean> addVirtualKeys​(UUID uuid,
                                                  String crateId,
                                                  long amount)
        Adds virtual crate keys to the player's data.

        When the player is online it will update the cache and will be persisted on the next data pool save.

        When the player is offline it will directly persist changes to the datasource.

        Parameters:
        uuid - the player's UUID
        crateId - the crate's identifier
        amount - the amount of keys to add
        Returns:
        CompletableFuture of Boolean indicating if the operation was successful
      • removeVirtualKeys

        CompletableFuture<Boolean> removeVirtualKeys​(UUID uuid,
                                                     String crateId,
                                                     long amount)
        Removes virtual crate keys from the player's data.

        When the player is online it will update the cache and will be persisted on the next data pool save.

        When the player is offline it will directly persist changes to the datasource.

        Parameters:
        uuid - the player's UUID
        crateId - the crate's identifier
        amount - the amount of keys to remove
        Returns:
        CompletableFuture of Boolean indicating if the operation was successful
      • setVirtualKeys

        CompletableFuture<Boolean> setVirtualKeys​(UUID uuid,
                                                  String crateId,
                                                  long amount)
        Sets the virtual crate keys for the player's data.

        When the player is online it will update the cache and will be persisted on the next data pool save.

        When the player is offline it will directly persist changes to the datasource.

        Parameters:
        uuid - the player's UUID
        crateId - the crate's identifier
        amount - the amount of keys to set
        Returns:
        CompletableFuture of Boolean indicating if the operation was successful
      • incrementUsedKeys

        CompletableFuture<Boolean> incrementUsedKeys​(UUID uuid,
                                                     String crateId,
                                                     long amount)
        Increments the used keys for the player's data.

        When the player is online it will update the cache and will be persisted on the next data pool save.

        When the player is offline it will directly persist changes to the datasource.

        Parameters:
        uuid - the player's UUID
        crateId - the crate's identifier
        amount - the amount of keys to increment
        Returns:
        CompletableFuture of Boolean indicating if the operation was successful