Klasse ArenaSession

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

public final class ArenaSession extends Object
A single in-progress instance of an arena: its participants, lifecycle state and timers.

The session drives the lobby flow: players join into ArenaState.WAITING, ready up, and once everyone is ready (and the minimum is met) a ArenaState.COUNTDOWN runs before the round starts (ArenaState.RUNNING). Joining or losing readiness during the countdown cancels it. The wave loop is layered onto the running state in a later milestone.

Timers use the Bukkit scheduler. On a regionised server (Folia) these would move to the region scheduler; that migration is deferred until threading is addressed.

  • Felddetails

    • DAMAGE_PROBE_METADATA

      public static final String DAMAGE_PROBE_METADATA
      Metadata key marking the invulnerability probe hit, so the lobby damage shield lets the probe through instead of masking god mode.
      Siehe auch:
  • Konstruktordetails

    • ArenaSession

      public ArenaSession(@NotNull @NotNull MobArenaPlugin plugin, @NotNull @NotNull Arena arena, @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, used for scheduling
      arena - the arena this session is running
      config - the configuration manager, read for lobby thresholds
      messages - the message renderer for broadcasts
      mobRegistry - the mob registry used by the wave engine
      mobScaler - the mob scaler used by the wave engine
      bossRegistry - the boss registry used by the wave engine
      waveSetRegistry - the wave-set registry used to resolve the arena's roster
      classRegistry - the class registry used to resolve loadouts
      progression - the progression service used for class levels
      rewardService - the wave-reward service used for wave-completion rewards
      rewardCache - the reward cache holding rewards that did not fit a full inventory
      stashStore - the persistent stash store guarding against crashes mid-round
      statsService - the statistics service recording rounds and best waves
      petService - the pet service spawning and cleaning up companions
  • Methodendetails

    • arena

      @NotNull public @NotNull Arena arena()
      Gibt zurück:
      the arena this session belongs to
    • setEndCallback

      public void setEndCallback(@NotNull @NotNull Runnable endCallback)
      Registers a callback invoked when the session ends, regardless of which code path ended it. The session manager uses this to drop the session from its lookup maps, so an internally triggered end (for example a game over after the last elimination) never leaves stale index entries behind.
      Parameter:
      endCallback - the callback to run on end
    • setKickCallback

      public void setKickCallback(@NotNull Consumer<Player> kickCallback)
      Registers a callback invoked when the session removes a player on its own initiative (for example a not-ready kick when the lobby countdown expires), so the session manager can drop its player-index entry.
      Parameter:
      kickCallback - the callback receiving the removed player
    • size

      public int size()
      Gibt zurück:
      the number of players in this session
    • notReadyNames

      @NotNull public @NotNull List<String> notReadyNames()
      Gibt zurück:
      the names of lobby players who have not readied up yet
    • participantNames

      @NotNull public @NotNull List<String> participantNames()
      Gibt zurück:
      the names of everyone currently in this session
    • readyPlayers

      public int readyPlayers()
      Gibt zurück:
      the number of players who have readied up
    • currentWave

      public int currentWave()
      Gibt zurück:
      the current wave number, or 0 while no round is running
    • countChosen

      public int countChosen(@NotNull @NotNull String className)
      Counts how many players have chosen the given class in this session.
      Parameter:
      className - the class identifier
      Gibt zurück:
      the number of players with that class chosen
    • state

      @NotNull public @NotNull ArenaState state()
      Gibt zurück:
      the current lifecycle state
    • isEmpty

      public boolean isEmpty()
      Gibt zurück:
      true if no players remain in the session
    • playerIds

      @NotNull public @NotNull Set<UUID> playerIds()
      Gibt zurück:
      an immutable copy of the participating player ids
    • acceptsJoins

      public boolean acceptsJoins()
      Gibt zurück:
      true if players may still join (the round has not started)
    • add

      public void add(@NotNull @NotNull Player player)
      Adds a player to the lobby, capturing and clearing their state.
      Parameter:
      player - the joining player
    • remove

      public boolean remove(@NotNull @NotNull Player player)
      Removes a player and restores their captured state.
      Parameter:
      player - the leaving player
      Gibt zurück:
      true if the player was part of this session
    • removeQuietly

      public boolean removeQuietly(@NotNull @NotNull Player player)
      Removes a disconnecting player without restoring their captured state. Their stash stays persisted in stashes.yml (server-restart proof) and is applied on their next join: original position, original inventory. Rewards earned so far go into the reward cache and are delivered on rejoin.
      Parameter:
      player - the disconnecting player
      Gibt zurück:
      true if the player was part of this session
    • eliminate

      public void eliminate(@NotNull @NotNull Player player)
      Eliminates a player from the running round. The player is healed, cleared of effects, dropped into spectator mode at the spectator warp and no longer counts as a live fighter. When no live players remain the round ends with a game-over message.
      Parameter:
      player - the player to eliminate
    • setReady

      public void setReady(@NotNull @NotNull Player player, boolean ready)
      Sets a player's ready flag and starts or cancels the countdown accordingly.
      Parameter:
      player - the player
      ready - the new ready state
    • isReady

      public boolean isReady(@NotNull @NotNull Player player)
      Parameter:
      player - the player
      Gibt zurück:
      whether the player is currently flagged ready
    • inLobby

      public boolean inLobby()
      Gibt zurück:
      true if the session is in its lobby phase (waiting or counting down)
    • forceStart

      public void forceStart()
      Immediately starts the round, skipping any remaining countdown. Has no effect once the round is already running or ended.
    • end

      public void end()
      Ends the round, restoring every remaining player. Idempotent.
    • chosenClass

      @Nullable public @Nullable String chosenClass(@NotNull @NotNull Player player)
      Returns the class a player has chosen in this session, if any.
      Parameter:
      player - the player
      Gibt zurück:
      the chosen class identifier, or null
    • setChosenClass

      public void setChosenClass(@NotNull @NotNull Player player, @NotNull @NotNull String className)
      Records a player's class choice. Only meaningful before the round starts.
      Parameter:
      player - the player
      className - the chosen class identifier
    • onlinePlayers

      @NotNull public @NotNull List<Player> onlinePlayers()
      Gibt zurück:
      the online players currently in this session
    • livingPlayers

      @NotNull public @NotNull List<Player> livingPlayers()
      Gibt zurück:
      the online players still alive (not eliminated) in this session; these are the fighters the wave engine spawns for and mobs target
    • announce

      public void announce(@NotNull @NotNull String miniMessage)
      Broadcasts a MiniMessage line (with the arena prefix) to everyone in this session. Public for collaborating systems such as the boss loot handler.
      Parameter:
      miniMessage - the message
    • trackPlacedBlock

      public void trackPlacedBlock(@NotNull Block block)
      Tracks a block a fighter placed during the round (tactical building). Tracked blocks may be broken again, pop in explosions, and are removed when the round ends.
      Parameter:
      block - the placed block
    • isPlacedBlock

      public boolean isPlacedBlock(@NotNull Block block)
      Parameter:
      block - the block to test
      Gibt zurück:
      whether the block was placed during this round
    • untrackPlacedBlock

      public void untrackPlacedBlock(@NotNull Block block)
      Untracks a placed block (after it was broken or blown up).
      Parameter:
      block - the block
    • addRoundKill

      public void addRoundKill(@NotNull @NotNull Player player)