From 684383a978f8e7fad9d5f9a28d0b49e154d73b67 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 19 Aug 2023 18:37:31 +0200 Subject: [PATCH] Improve Game Countdown --- src/de/steamwar/towerrun/TowerRun.java | 6 +++++- src/de/steamwar/towerrun/config/Config.java | 2 ++ src/de/steamwar/towerrun/countdowns/GameCountdown.java | 2 +- .../towerrun/winconditions/OutsideWincondition.java | 4 ++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/towerrun/TowerRun.java b/src/de/steamwar/towerrun/TowerRun.java index 8754089..3c2ec52 100644 --- a/src/de/steamwar/towerrun/TowerRun.java +++ b/src/de/steamwar/towerrun/TowerRun.java @@ -50,6 +50,10 @@ public class TowerRun extends JavaPlugin { @Getter private static Message message; + @Getter + private static GameCountdown gameCountdown; + + @Override public void onEnable() { instance = this; @@ -63,6 +67,6 @@ public class TowerRun extends JavaPlugin { final LobbyCountdown lobbyCountdown = new LobbyCountdown(); new EndCountdown(lobbyCountdown); new StartCommand(lobbyCountdown); - new GameCountdown(); + gameCountdown = new GameCountdown(); } } diff --git a/src/de/steamwar/towerrun/config/Config.java b/src/de/steamwar/towerrun/config/Config.java index b77f50e..7890e78 100644 --- a/src/de/steamwar/towerrun/config/Config.java +++ b/src/de/steamwar/towerrun/config/Config.java @@ -37,6 +37,7 @@ public class Config { public static final int LOBBY_TIMER; public static final Set DESTROYABLE_BLOCKS; public static final int GAME_TIMER; + public static final int GAME_ESCAPE_TIMER; static { File configFile = new File(TowerRun.getInstance().getDataFolder(), "config.yml"); @@ -50,6 +51,7 @@ public class Config { MIN_PLAYERS = config.getInt("minPlayers"); LOBBY_TIMER = config.getInt("lobbyTimer"); GAME_TIMER = config.getInt("gameTimer", 20 * 60); + GAME_ESCAPE_TIMER = config.getInt("gameEscapeTimer", 60); DESTROYABLE_BLOCKS = EnumSet.copyOf(config.getStringList("destroyable").stream().map(Material::valueOf).collect(Collectors.toSet())); } diff --git a/src/de/steamwar/towerrun/countdowns/GameCountdown.java b/src/de/steamwar/towerrun/countdowns/GameCountdown.java index f5d23ef..8a5f878 100644 --- a/src/de/steamwar/towerrun/countdowns/GameCountdown.java +++ b/src/de/steamwar/towerrun/countdowns/GameCountdown.java @@ -56,6 +56,6 @@ public class GameCountdown extends Countdown { int timeMinutes = Math.floorDiv(time, 60); int timeSeconds = time % 60; - TowerRun.getMessage().broadcastActionbar("GAME_TIME", timeMinutes, timeSeconds); + TowerRun.getMessage().broadcastActionbar("GAME_TIME", String.format("%02d", timeMinutes), String.format("%02d", timeSeconds)); } } diff --git a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java index 6864d7d..9419e7e 100644 --- a/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java +++ b/src/de/steamwar/towerrun/winconditions/OutsideWincondition.java @@ -20,6 +20,7 @@ package de.steamwar.towerrun.winconditions; import de.steamwar.towerrun.TowerRun; +import de.steamwar.towerrun.config.Config; import de.steamwar.towerrun.config.WorldConfig; import de.steamwar.towerrun.game.TowerRunGame; import de.steamwar.towerrun.game.TowerRunPlayer; @@ -65,5 +66,8 @@ public abstract class OutsideWincondition extends WinCondition { TowerRunGame.PLAYERS_ALIVE.remove(towerRunPlayer); towerRunPlayer.player().setGameMode(GameMode.SPECTATOR); TowerRun.getMessage().broadcast("PLAYER_ESCAPE", towerRunPlayer.player().getName()); + if (TowerRunGame.PLAYERS_ESCAPED.size() == 1) { + TowerRun.getGameCountdown().setTime(Config.GAME_ESCAPE_TIMER); + } } }