Package com.yottabyte.crates.api.data
Interface DataManager
-
public interface DataManager
The manager for all data related operations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableFuture<Boolean>
addVirtualKeys(UUID uuid, String crateId, long amount)
Adds virtual crate keys to the player's data.CompletableFuture<PlayerData>
fetchPlayerData(UUID uuid)
Fetches the player data from the data source.PlayerData
getPlayerData(UUID uuid)
Gets the player data from the cache.CompletableFuture<Boolean>
incrementUsedKeys(UUID uuid, String crateId, long amount)
Increments the used keys for the player's data.void
loadPlayerData(UUID uuid)
Loads the player data from the data source and caches it asynchronously.void
reload()
Reloads everything data related.CompletableFuture<Boolean>
removeVirtualKeys(UUID uuid, String crateId, long amount)
Removes virtual crate keys from the player's data.int
saveDataPool()
Saves all data to the data pool.CompletableFuture<Boolean>
setVirtualKeys(UUID uuid, String crateId, long amount)
Sets the virtual crate keys for the player's data.void
shutdown()
Saves all data to the data pool and then shuts all data pools down.void
unloadPlayerData(UUID uuid)
Unloads the player data from the cache and saves it to the data source asynchronously.
-
-
-
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.
-
fetchPlayerData
CompletableFuture<PlayerData> fetchPlayerData(UUID uuid)
Fetches the player data from the data source.- Parameters:
uuid
- the player's UUID- Returns:
CompletableFuture
ofPlayerData
-
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 UUIDcrateId
- the crate's identifieramount
- the amount of keys to add- Returns:
CompletableFuture
ofBoolean
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 UUIDcrateId
- the crate's identifieramount
- the amount of keys to remove- Returns:
CompletableFuture
ofBoolean
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 UUIDcrateId
- the crate's identifieramount
- the amount of keys to set- Returns:
CompletableFuture
ofBoolean
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 UUIDcrateId
- the crate's identifieramount
- the amount of keys to increment- Returns:
CompletableFuture
ofBoolean
indicating if the operation was successful
-
-