From fd51d09da2c9c29220214d2fdd662010c6541be6 Mon Sep 17 00:00:00 2001 From: boiscljo Date: Sat, 2 Apr 2022 10:16:37 -0400 Subject: [PATCH] fix countdown --- .../io/github/pronze/sba/listener/BedWarsListener.java | 4 ++-- .../github/pronze/sba/visuals/LobbyScoreboardManager.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/io/github/pronze/sba/listener/BedWarsListener.java b/plugin/src/main/java/io/github/pronze/sba/listener/BedWarsListener.java index a0922e42..ca734b30 100644 --- a/plugin/src/main/java/io/github/pronze/sba/listener/BedWarsListener.java +++ b/plugin/src/main/java/io/github/pronze/sba/listener/BedWarsListener.java @@ -203,7 +203,7 @@ public void run() { if (!time.contains("0-1")) { String[] units = time.split(":"); - int seconds = Integer.parseInt(units[1]) + 1; + int seconds = Integer.parseInt(units[1]) + 1 + Integer.parseInt(units[0])*60; if (buffer == seconds) return; buffer = seconds; @@ -211,7 +211,7 @@ public void run() { var message = LanguageService .getInstance() .get(MessageKeys.GAME_STARTS_IN_MESSAGE) - .replace("%seconds%", String.valueOf(seconds)) + .replace("%seconds%", seconds <=60 ? String.valueOf(seconds): game.getFormattedTimeLeft()) .toString(); message = seconds == 1 ? message diff --git a/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java b/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java index b6498f39..57b09a5a 100644 --- a/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java +++ b/plugin/src/main/java/io/github/pronze/sba/visuals/LobbyScoreboardManager.java @@ -144,15 +144,15 @@ else if (game.getAvailableTeams().stream().allMatch(t -> t.getMaxPlayers() == 4) if (game.countConnectedPlayers() >= game.getMinPlayers() && game.getStatus() == GameStatus.WAITING) { - final var time = ((org.screamingsandals.bedwars.game.Game) Main.getInstance().getGameByName(game.getName())) - .getFormattedTimeLeft(); + final var gameImpl = ((org.screamingsandals.bedwars.game.Game) game); + final var time = gameImpl.getFormattedTimeLeft(); if (!time.contains("0-1")) { final var units = time.split(":"); - var seconds = Integer.parseInt(units[1]) + 1; + int seconds = Integer.parseInt(units[1]) + 1 + Integer.parseInt(units[0])*60; state = LanguageService .getInstance() .get(MessageKeys.LOBBY_SCOREBOARD_STATE) - .replace("%countdown%", String.valueOf(seconds)) + .replace("%countdown%", seconds <=60 ? String.valueOf(seconds): gameImpl.getFormattedTimeLeft()) .toString(); } }