Klasse StatsService

java.lang.Object
de.delinkedde.mobarenareborn.stats.StatsService

public final class StatsService extends Object
Tracks per-player, per-arena statistics (kills, rounds, best wave) and the global leaderboard.

Stats are loaded into an in-memory cache when a player joins, mutated during play and persisted through the shared database thread at the same points as class progression (round end, quit, autosave, shutdown). The best-wave leaderboard is refreshed asynchronously on start-up and every few minutes; readers always see the last completed snapshot.

  • Felddetails

    • TOP_LIMIT

      public static final int TOP_LIMIT
      Maximum number of leaderboard rows kept in the cached snapshot.
      Siehe auch:
  • Konstruktordetails

    • StatsService

      public StatsService(@NotNull @NotNull MobArenaPlugin plugin, @NotNull @NotNull StatsDao dao, @NotNull @NotNull DbExecutor dbExecutor)
      Parameter:
      plugin - the owning plugin, used for logging
      dao - the data access object for stats
      dbExecutor - the shared database thread
  • Methodendetails

    • load

      public void load(@NotNull @NotNull Player player)
      Loads a player's stored stats into the cache.
      Parameter:
      player - the joining player
    • stats

      @NotNull public @NotNull PlayerStats stats(@NotNull @NotNull UUID uuid, @NotNull @NotNull String arena)
      Returns the player's stats for an arena, creating a fresh entry if absent.
      Parameter:
      uuid - the player's unique id
      arena - the arena identifier
      Gibt zurück:
      the mutable stats
    • allStats

      @NotNull public @NotNull Map<String,PlayerStats> allStats(@NotNull @NotNull UUID uuid)
      Parameter:
      uuid - the player's unique id
      Gibt zurück:
      an immutable snapshot of all cached per-arena stats of the player
    • addKill

      public void addKill(@NotNull @NotNull Player player, @NotNull @NotNull String arena)
      Counts an arena-mob kill.
      Parameter:
      player - the killer
      arena - the arena identifier
    • recordRound

      public void recordRound(@NotNull @NotNull UUID uuid, @NotNull @NotNull String arena, int waveReached)
      Records a finished round for a player and persists their stats.
      Parameter:
      uuid - the player's unique id
      arena - the arena identifier
      waveReached - the wave the round ended on
    • flush

      public void flush(@NotNull @NotNull UUID uuid)
      Persists all cached stats of a player.
      Parameter:
      uuid - the player's unique id
    • flushAll

      public void flushAll()
      Persists all cached stats of every player.
    • unload

      public void unload(@NotNull @NotNull UUID uuid)
      Drops a player's cached stats after a final flush.
      Parameter:
      uuid - the player's unique id
    • top

      @NotNull public @NotNull List<StatsDao.TopEntry> top()
      Gibt zurück:
      the last completed best-wave leaderboard snapshot, best first
    • refreshTop

      public void refreshTop()
      Refreshes the leaderboard snapshot on the database thread.