player data api

The PlayerDataAPI provides methods to manage player data and caching.

Getting the API

ZelBountyAPI api = Bukkit.getServicesManager().load(ZelBountyAPI.class);
PlayerDataAPI playerDataAPI = api.getPlayerDataAPI();

Methods

getPlayer

Get cached player data synchronously.

@Nullable IBountyPlayer getPlayer(UUID uuid);

Parameters:

  • uuid - Player's UUID

Returns: IBountyPlayer object or null if not cached

IBountyPlayer Interface:

public interface IBountyPlayer {
    UUID getUUID();
    String getName();
    IBountyData getBountyData();
    boolean isOnline();
}

Example:


loadPlayer

Load player data asynchronously from the database.

Parameters:

  • uuid - Player's UUID

Returns: CompletableFuture<IBountyPlayer> - Loaded player data

Example:


savePlayer

Save player data asynchronously to the database.

Parameters:

  • uuid - Player's UUID

Returns: CompletableFuture<Void> - Completes when saved

Example:


isPlayerLoaded

Check if a player is currently loaded in the cache.

Parameters:

  • uuid - Player's UUID

Returns: true if player data is in memory cache

Example:


reloadAllData

Reload all player data from the database.

Returns: CompletableFuture<Void> - Completes when all data is reloaded

Example:

Data Models

IBountyPlayer

Represents a player with bounty data.

IBountyData

Contains bounty statistics for a player.

Caching Behavior

  • Players are automatically loaded when they join the server

  • Players are saved and unloaded when they leave

  • Use isPlayerLoaded() to check if data is available synchronously

  • Always use loadPlayer() for offline players

Complete Example