Class PlayerStatistics

java.lang.Object
com.github.darksoulq.abyssallib.world.data.statistic.PlayerStatistics

public class PlayerStatistics extends Object
Manages the loading, storing, and tracking of individual player statistics safely integrated with a local relational database instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    get(Statistic stat)
    Gets the current integer value of a specified statistic.
    Retrieves an immutable copy of the active in-memory statistics cache.
    void
    increment(Statistic stat, int amount)
    Increments the tracked value of a specified statistic safely dispatching events.
    static void
    Initializes the statistics database connection and ensures the necessary tables exist.
    of(org.bukkit.entity.Player player)
    Retrieves the statistics cache wrapper for a specific player.
    void
    set(Statistic stat, int newValue)
    Overwrites the tracked value of a specified statistic and synchronizes it to the database.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • init

      public static void init() throws Exception
      Initializes the statistics database connection and ensures the necessary tables exist.
      Throws:
      Exception - If database connection or schema creation fails.
    • of

      public static PlayerStatistics of(org.bukkit.entity.Player player)
      Retrieves the statistics cache wrapper for a specific player.
      Parameters:
      player - The Bukkit player.
      Returns:
      The bound PlayerStatistics instance.
    • get

      public int get(Statistic stat)
      Gets the current integer value of a specified statistic.
      Parameters:
      stat - The target statistic.
      Returns:
      The tracked value, or 0 if unrecorded.
    • increment

      public void increment(Statistic stat, int amount)
      Increments the tracked value of a specified statistic safely dispatching events.
      Parameters:
      stat - The target statistic.
      amount - The integer amount to append.
    • set

      public void set(Statistic stat, int newValue)
      Overwrites the tracked value of a specified statistic and synchronizes it to the database.
      Parameters:
      stat - The target statistic.
      newValue - The exact new integer value to set.
    • getAll

      public Map<Statistic, Integer> getAll()
      Retrieves an immutable copy of the active in-memory statistics cache.
      Returns:
      The map snapshot of active statistics.