Klasse StatsService
java.lang.Object
de.delinkedde.mobarenareborn.stats.StatsService
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.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final intMaximum number of leaderboard rows kept in the cached snapshot. -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungStatsService(@NotNull MobArenaPlugin plugin, @NotNull StatsDao dao, @NotNull DbExecutor dbExecutor) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidCounts an arena-mob kill.@NotNull Map<String, PlayerStats> voidPersists all cached stats of a player.voidflushAll()Persists all cached stats of every player.voidLoads a player's stored stats into the cache.voidrecordRound(@NotNull UUID uuid, @NotNull String arena, int waveReached) Records a finished round for a player and persists their stats.voidRefreshes the leaderboard snapshot on the database thread.@NotNull PlayerStatsReturns the player's stats for an arena, creating a fresh entry if absent.@NotNull List<StatsDao.TopEntry> top()voidDrops a player's cached stats after a final flush.
-
Felddetails
-
TOP_LIMIT
public static final int TOP_LIMITMaximum 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 loggingdao- the data access object for statsdbExecutor- the shared database thread
-
-
Methodendetails
-
load
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 idarena- the arena identifier- Gibt zurück:
- the mutable stats
-
allStats
- Parameter:
uuid- the player's unique id- Gibt zurück:
- an immutable snapshot of all cached per-arena stats of the player
-
addKill
Counts an arena-mob kill.- Parameter:
player- the killerarena- 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 idarena- the arena identifierwaveReached- the wave the round ended on
-
flush
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
Drops a player's cached stats after a final flush.- Parameter:
uuid- the player's unique id
-
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.
-