Klasse SessionManager

java.lang.Object
de.delinkedde.mobarenareborn.session.SessionManager

public final class SessionManager extends Object
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.

  • 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 plugin
      config - the configuration manager passed to new sessions
      messages - the message renderer passed to new sessions
      mobRegistry - the mob registry passed to new sessions
      mobScaler - the mob scaler passed to new sessions
      bossRegistry - the boss registry passed to new sessions
      waveSetRegistry - the wave-set registry passed to new sessions
      classRegistry - the class registry passed to new sessions
      progression - the progression service for load/flush and new sessions
      rewardService - the wave-reward service passed to new sessions
      rewardCache - the reward cache passed to new sessions for undeliverable rewards
      stashStore - the persistent stash store passed to new sessions
      statsService - the statistics service passed to new sessions
  • Methodendetails

    • setEndListener

      public void setEndListener(@NotNull Consumer<String> endListener)
      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-distance keeps far-away players out, and join-warmup-seconds makes 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 player
      arena - the target arena
      feedback - receives the final result exactly once
    • join

      @NotNull public @NotNull SessionManager.JoinResult join(@NotNull @NotNull Player player, @NotNull @NotNull Arena arena)
    • leave

      public boolean leave(@NotNull @NotNull Player player)
      Removes a player from their session, ending the session if it becomes empty.
      Parameter:
      player - the leaving player
      Gibt zurück:
      true if the player was in a session
    • leaveOnDisconnect

      public boolean leaveOnDisconnect(@NotNull @NotNull Player player)
      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:
      true if the player was in a session
    • ready

      public boolean ready(@NotNull @NotNull Player player, boolean ready)
      Sets a player's ready state.
      Parameter:
      player - the player
      ready - the new ready state
      Gibt zurück:
      true if 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 player
      className - the chosen class identifier
      Gibt zurück:
      the outcome
    • arenaViewOf

      public String arenaViewOf(@NotNull @NotNull UUID uuid)
      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 null when not in a session
    • sessionWithPlacedBlock

      @NotNull public @NotNull Optional<ArenaSession> sessionWithPlacedBlock(@NotNull Block block)
      Parameter:
      block - the block to test
      Gibt zurück:
      the session that tracked this block as player-placed, if any
    • endSessionsInWorld

      public void endSessionsInWorld(@NotNull @NotNull String worldName)
      Ends every session whose arena lies in the given world (used before a world unloads).
      Parameter:
      worldName - the unloading world's name
    • sessionFor

      @NotNull public @NotNull Optional<ArenaSession> sessionFor(@NotNull @NotNull String arenaName)
    • sessionOf

      @NotNull public @NotNull Optional<ArenaSession> sessionOf(@NotNull @NotNull Player player)
    • hasActiveSession

      public boolean hasActiveSession(@NotNull @NotNull String arenaName)
      Parameter:
      arenaName - the arena identifier
      Gibt zurück:
      whether the arena currently has an active (not ended) session
    • forceStart

      public boolean forceStart(@NotNull @NotNull String arenaName)
      Forcibly starts an arena's round, skipping the countdown.
      Parameter:
      arenaName - the arena identifier
      Gibt zurück:
      true if a session existed and was started
    • forceEnd

      public boolean forceEnd(@NotNull @NotNull String arenaName)
      Forcibly ends an arena's round, restoring all players.
      Parameter:
      arenaName - the arena identifier
      Gibt zurück:
      true if a session existed and was ended
    • endAll

      public void endAll()
      Ends every session and restores all players. Intended for plugin shutdown.