Klasse ProgressionService
java.lang.Object
de.delinkedde.mobarenareborn.progression.ProgressionService
Tracks per-player, per-class experience and levels and persists them.
Progress is loaded into an in-memory cache when a player joins, mutated as they earn
experience, and saved on level-up and when they leave. The level-up threshold comes from the
leveling.curve expression, evaluated with the level variable.
Database access is serialised onto a single background thread so the SQLite connection is never used concurrently and never blocks the main server thread during a wave. Writes (level-up and leave flushes) are submitted asynchronously; the join-time load is run on the same executor and awaited, which keeps the cache ready before the round and guarantees ordered access. The shared executor is drained by the service container on shutdown, before the database closes.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungProgressionService(@NotNull MobArenaPlugin plugin, @NotNull ConfigManager config, @NotNull ClassLevelDao dao, @NotNull DbExecutor dbExecutor) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidAwards experience to a player's class, applying any level-ups and persisting on change.voidPersists all cached progress for a player.voidflushAll()Persists all cached progress for every player.voidLoads a player's stored progress into the cache.@NotNull ClassProgressReturns the player's progress for a class, creating a fresh level-one entry if absent.voidDrops a player's cached progress after a final flush.longxpForNextLevel(int level) Returns the experience required to advance from the given level to the next.
-
Konstruktordetails
-
ProgressionService
public ProgressionService(@NotNull @NotNull MobArenaPlugin plugin, @NotNull @NotNull ConfigManager config, @NotNull @NotNull ClassLevelDao dao, @NotNull @NotNull DbExecutor dbExecutor) - Parameter:
plugin- the owning plugin, used for loggingconfig- the configuration manager providing the level curvedao- the data access object for class levelsdbExecutor- the shared database thread
-
-
Methodendetails
-
load
Loads a player's stored progress into the cache.- Parameter:
uuid- the player's unique id
-
progress
@NotNull public @NotNull ClassProgress progress(@NotNull @NotNull UUID uuid, @NotNull @NotNull String className) Returns the player's progress for a class, creating a fresh level-one entry if absent.- Parameter:
uuid- the player's unique idclassName- the class identifier- Gibt zurück:
- the progress
-
xpForNextLevel
public long xpForNextLevel(int level) Returns the experience required to advance from the given level to the next.- Parameter:
level- the current level- Gibt zurück:
- the threshold, at least one
-
awardXp
public void awardXp(@NotNull @NotNull Player player, @NotNull @NotNull String className, int maxLevel, long amount) Awards experience to a player's class, applying any level-ups and persisting on change.- Parameter:
player- the playerclassName- the class identifiermaxLevel- the class level capamount- the experience to award
-
flush
Persists all cached progress for a player.- Parameter:
uuid- the player's unique id
-
flushAll
public void flushAll()Persists all cached progress for every player. Used by the periodic autosave and on plugin shutdown (before the background executor is drained) so banked experience is never lost when players are still online. -
unload
Drops a player's cached progress after a final flush.- Parameter:
uuid- the player's unique id
-