From f6ac150a8f6e7511dd924ef8f18eb390d3cb5085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20M=C3=BCller?= Date: Sun, 18 Oct 2026 17:53:13 +0200 Subject: [PATCH] arena: challenger idling 1 min in the options gets sent back to the tribune --- .../spawn/arena/appliances/arena/Lobby.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arena/src/main/java/eu/mhsl/craftattack/spawn/arena/appliances/arena/Lobby.java b/arena/src/main/java/eu/mhsl/craftattack/spawn/arena/appliances/arena/Lobby.java index 970a3a5..0727830 100644 --- a/arena/src/main/java/eu/mhsl/craftattack/spawn/arena/appliances/arena/Lobby.java +++ b/arena/src/main/java/eu/mhsl/craftattack/spawn/arena/appliances/arena/Lobby.java @@ -16,6 +16,7 @@ import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.entity.TextDisplay; import org.bukkit.util.Vector; +import org.jetbrains.annotations.Nullable; import java.time.Duration; import java.util.HashMap; @@ -33,6 +34,8 @@ final class Lobby implements PadLobby.Listener { private static final double PUSH_MARGIN = 0.4; /** How long a full lobby waits for the challenger to close the options. */ private static final int CHOOSING_SECONDS = 20; + /** Whoever keeps the options open this long without clicking anything gets sent off the pad. */ + private static final int MENU_IDLE_TICKS = 60 * 20; private final Arena arena; private final Region[] regions; @@ -40,6 +43,8 @@ final class Lobby implements PadLobby.Listener { private final TextDisplay[] displays = new TextDisplay[PadLobby.PADS]; private final Map lastPushSound = new HashMap<>(); private long ticks; + private @Nullable UUID menuViewer; + private int menuIdleTicks; Lobby(Arena arena, Region[] regions) { this.arena = arena; @@ -59,12 +64,23 @@ final class Lobby implements PadLobby.Listener { else if(state == Arena.PlayerState.TRIBUNE) this.checkEnter(player); } + this.checkMenuIdle(); this.pads.tick(this.arena.hasFreeSlot()); if(this.ticks % 3 == 0) this.drawParticles(); if(this.ticks % 5 == 0) this.updateDisplays(); } + private void checkMenuIdle() { + if(this.menuViewer == null || ++this.menuIdleTicks < MENU_IDLE_TICKS) return; + Player player = Bukkit.getPlayer(this.menuViewer); + this.menuViewer = null; + if(player == null || !ModeMenu.isOpen(player)) return; + this.arena.toTribune(player); + player.sendMessage(Style.message("Du hast eine Minute lang nichts ausgewählt und wurdest vom Feld geschickt.")); + Style.play(player, Sound.BLOCK_NOTE_BLOCK_BASS, 0.6f); + } + private void checkLeave(Player player) { int pad = this.pads.padOf(player.getUniqueId()); if(pad != -1 && this.isOn(player, pad, 0)) return; @@ -108,6 +124,7 @@ final class Lobby implements PadLobby.Listener { int ownSize = menu.ownSize; int opponentSize = menu.opponentSize; FightMode mode = menu.mode; + this.menuIdleTicks = 0; switch(click) { case ModeMenu.OwnSize(int size) -> ownSize = size; case ModeMenu.OpponentSize(int size) -> opponentSize = size; @@ -152,6 +169,8 @@ final class Lobby implements PadLobby.Listener { int pad = this.pads.challengerPad(); InteractSounds.of(player).open(); ModeMenu.open(player, pad, this.pads.size(pad), this.pads.size(1 - pad), this.pads.mode()); + this.menuViewer = player.getUniqueId(); + this.menuIdleTicks = 0; this.pads.setChoosing(player.getUniqueId(), true); return true; } @@ -160,6 +179,7 @@ final class Lobby implements PadLobby.Listener { * The challenger closed the options: a full lobby starts counting down now. */ void menuClosed(Player player) { + if(player.getUniqueId().equals(this.menuViewer)) this.menuViewer = null; this.pads.setChoosing(player.getUniqueId(), false); }