Interface StatsAPI
public interface StatsAPI
-
Method Summary
Modifier and TypeMethodDescription<T> CompletableFuture
<T> Gets a player's statistics asynchronously for a specificDataType
.<T> T
Gets a player's statistics synchronously for a specificDataType
.Loads a player's statistics asynchronously using the player'sUUID
.load
(@NotNull org.bukkit.entity.Player player) Loads a player's statistics asynchronously using the player'sPlayer
object.void
load
(@NotNull org.bukkit.entity.Player player, Consumer<CloudPlayerData> callback) Loads a player's statistics asynchronously using the player'sPlayer
object and executes a callback with the results.void
save
(@NotNull org.bukkit.entity.Player player) Saves a player's statistics cache to the database asynchronously.saveAll()
Saves all player data in the cache to the database asynchronously.void
Sets a player's statistics asynchronously.void
unload
(@NotNull org.bukkit.entity.Player player) Unloads a player's statistics from the cache.
-
Method Details
-
load
Loads a player's statistics asynchronously using the player'sPlayer
object.This method fetches the player's statistics from the database or cache.
- Parameters:
player
- The player whose statistics are to be loaded.- Returns:
- A CompletableFuture containing the loaded
CloudPlayerData
for the player.
-
load
Loads a player's statistics asynchronously using the player'sUUID
.This method fetches the player's statistics from the database or cache.
- Parameters:
uuid
- The UUID of the player whose statistics are to be loaded.- Returns:
- A CompletableFuture containing the loaded
CloudPlayerData
for the player.
-
load
Loads a player's statistics asynchronously using the player'sPlayer
object and executes a callback with the results.This method fetches the player's statistics and provides them via the callback.
- Parameters:
player
- The player whose statistics are to be loaded.callback
- The callback to execute once the player's statistics are loaded.
-
set
Sets a player's statistics asynchronously.This method updates the player's statistics for a specific
DataType
and the given value.- Parameters:
player
- The player whose statistics are to be updated.type
- The type of data being set (e.g., kills, wins, losses).value
- The value to set for the specifiedDataType
.
-
get
Gets a player's statistics asynchronously for a specificDataType
.This method fetches the player's statistics for a specific data type.
- Type Parameters:
T
- The type of value returned for the specifiedDataType
.- Parameters:
player
- The player whose statistics are to be retrieved.type
- The type of data being retrieved (e.g., kills, wins, losses).- Returns:
- A CompletableFuture containing the value of the specified
DataType
for the player.
-
getSync
Gets a player's statistics synchronously for a specificDataType
.This method fetches the player's statistics for a specific data type in a blocking manner.
-
save
void save(@NotNull @NotNull org.bukkit.entity.Player player) Saves a player's statistics cache to the database asynchronously.This method saves the player's current statistics from the cache to the database.
- Parameters:
player
- The player whose statistics cache is to be saved.
-
saveAll
CompletableFuture<Void> saveAll()Saves all player data in the cache to the database asynchronously.This method saves the statistics for all players in the cache to the database.
- Returns:
- A CompletableFuture indicating when the saving process is complete.
-
unload
void unload(@NotNull @NotNull org.bukkit.entity.Player player) Unloads a player's statistics from the cache.This method removes the player's statistics from the cache, typically when the player disconnects.
- Parameters:
player
- The player whose statistics are to be unloaded.
-