Klasse SessionManager
java.lang.Object
de.delinkedde.mobarenareborn.session.SessionManager
Owns the active
ArenaSession instances and the player-to-session index.
Sessions are created lazily when the first player joins an arena and discarded when the last player leaves. The manager is the single entry point for join, leave, ready and the administrative force operations, keeping the two lookup maps consistent.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic enumThe outcome of achooseClass(Player, String)attempt.static enumThe outcome of ajoin(Player, Arena)attempt. -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungSessionManager(@NotNull MobArenaPlugin plugin, @NotNull ConfigManager config, @NotNull Messages messages, @NotNull MobRegistry mobRegistry, @NotNull MobScaler mobScaler, @NotNull BossRegistry bossRegistry, @NotNull WaveSetRegistry waveSetRegistry, @NotNull ClassRegistry classRegistry, @NotNull ProgressionService progression, @NotNull RewardService rewardService, @NotNull RewardCache rewardCache, @NotNull StashStore stashStore, @NotNull StatsService statsService, @NotNull PetService petService) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungarenaViewOf(@NotNull UUID uuid) Thread-safe view of the arena name a player currently belongs to, for async readers such as the chat-isolation filter.@NotNull SessionManager.ClassChoicechooseClass(@NotNull Player player, @NotNull String className) Records a player's class choice in their session, enforcing the class's per-round limit.voidendAll()Ends every session and restores all players.voidendSessionsInWorld(@NotNull String worldName) Ends every session whose arena lies in the given world (used before a world unloads).booleanForcibly ends an arena's round, restoring all players.booleanforceStart(@NotNull String arenaName) Forcibly starts an arena's round, skipping the countdown.booleanhasActiveSession(@NotNull String arenaName) @NotNull SessionManager.JoinResultbooleanRemoves a player from their session, ending the session if it becomes empty.booleanleaveOnDisconnect(@NotNull Player player) Handles a disconnect.booleanSets a player's ready state.voidrequestJoin(@NotNull Player player, @NotNull Arena arena, Consumer<SessionManager.JoinResult> feedback) Requests a join, applying the join gate first:max-join-distancekeeps far-away players out, andjoin-warmup-secondsmakes the player stand still for a moment - so nobody escapes a PvP fight by hopping into the arena.@NotNull Optional<ArenaSession> sessionFor(@NotNull String arenaName) @NotNull Optional<ArenaSession> @NotNull Optional<ArenaSession> sessionWithPlacedBlock(Block block) voidsetEndListener(Consumer<String> endListener) Registers a listener notified with the arena name whenever a session ends, used to return spectators of that arena.
-
Konstruktordetails
-
SessionManager
public SessionManager(@NotNull @NotNull MobArenaPlugin plugin, @NotNull @NotNull ConfigManager config, @NotNull @NotNull Messages messages, @NotNull @NotNull MobRegistry mobRegistry, @NotNull @NotNull MobScaler mobScaler, @NotNull @NotNull BossRegistry bossRegistry, @NotNull @NotNull WaveSetRegistry waveSetRegistry, @NotNull @NotNull ClassRegistry classRegistry, @NotNull @NotNull ProgressionService progression, @NotNull @NotNull RewardService rewardService, @NotNull @NotNull RewardCache rewardCache, @NotNull @NotNull StashStore stashStore, @NotNull @NotNull StatsService statsService, @NotNull @NotNull PetService petService) - Parameter:
plugin- the owning pluginconfig- the configuration manager passed to new sessionsmessages- the message renderer passed to new sessionsmobRegistry- the mob registry passed to new sessionsmobScaler- the mob scaler passed to new sessionsbossRegistry- the boss registry passed to new sessionswaveSetRegistry- the wave-set registry passed to new sessionsclassRegistry- the class registry passed to new sessionsprogression- the progression service for load/flush and new sessionsrewardService- the wave-reward service passed to new sessionsrewardCache- the reward cache passed to new sessions for undeliverable rewardsstashStore- the persistent stash store passed to new sessionsstatsService- the statistics service passed to new sessions
-
-
Methodendetails
-
setEndListener
Registers a listener notified with the arena name whenever a session ends, used to return spectators of that arena.- Parameter:
endListener- the listener to notify
-
requestJoin
public void requestJoin(@NotNull @NotNull Player player, @NotNull @NotNull Arena arena, @NotNull Consumer<SessionManager.JoinResult> feedback) Requests a join, applying the join gate first:max-join-distancekeeps far-away players out, andjoin-warmup-secondsmakes the player stand still for a moment - so nobody escapes a PvP fight by hopping into the arena. The result is delivered to the feedback callback (immediately, or after the warm-up).- Parameter:
player- the joining playerarena- the target arenafeedback- receives the final result exactly once
-
join
@NotNull public @NotNull SessionManager.JoinResult join(@NotNull @NotNull Player player, @NotNull @NotNull Arena arena) -
leave
Removes a player from their session, ending the session if it becomes empty.- Parameter:
player- the leaving player- Gibt zurück:
trueif the player was in a session
-
leaveOnDisconnect
Handles a disconnect. During a running round the player is removed without being restored: the event is logged, their pre-arena state stays persisted (server-restart proof) and is applied on their next join - original position, original inventory. Outside a running round this behaves like a normal leave.- Parameter:
player- the disconnecting player- Gibt zurück:
trueif the player was in a session
-
ready
Sets a player's ready state.- Parameter:
player- the playerready- the new ready state- Gibt zurück:
trueif the player was in a session
-
chooseClass
@NotNull public @NotNull SessionManager.ClassChoice chooseClass(@NotNull @NotNull Player player, @NotNull @NotNull String className) Records a player's class choice in their session, enforcing the class's per-round limit.- Parameter:
player- the playerclassName- the chosen class identifier- Gibt zurück:
- the outcome
-
arenaViewOf
Thread-safe view of the arena name a player currently belongs to, for async readers such as the chat-isolation filter.- Parameter:
uuid- the player's unique id- Gibt zurück:
- the arena name, or
nullwhen not in a session
-
sessionWithPlacedBlock
- Parameter:
block- the block to test- Gibt zurück:
- the session that tracked this block as player-placed, if any
-
endSessionsInWorld
Ends every session whose arena lies in the given world (used before a world unloads).- Parameter:
worldName- the unloading world's name
-
sessionFor
-
sessionOf
-
hasActiveSession
- Parameter:
arenaName- the arena identifier- Gibt zurück:
- whether the arena currently has an active (not ended) session
-
forceStart
Forcibly starts an arena's round, skipping the countdown.- Parameter:
arenaName- the arena identifier- Gibt zurück:
trueif a session existed and was started
-
forceEnd
Forcibly ends an arena's round, restoring all players.- Parameter:
arenaName- the arena identifier- Gibt zurück:
trueif a session existed and was ended
-
endAll
public void endAll()Ends every session and restores all players. Intended for plugin shutdown.
-