From fe56e24bf0221b5dc4f34ad8529c42c48ddb94ba Mon Sep 17 00:00:00 2001 From: Misat11 <20199703+Misat11@users.noreply.github.com> Date: Wed, 24 Apr 2024 19:41:39 +0200 Subject: [PATCH] fix: fixed binary compatibility issue in addons particularly fixed SBA expecting non-static getFormattedTimeLeft(int) method --- .../screamingsandals/bedwars/game/Game.java | 13 ++++++++--- .../placeholderapi/BedwarsExpansion.java | 22 +++++++++---------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/game/Game.java b/plugin/src/main/java/org/screamingsandals/bedwars/game/Game.java index 87b9ed82d..d0ef7ed4e 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/game/Game.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/game/Game.java @@ -2139,7 +2139,7 @@ public void run() { for (CurrentTeam t : teamsInGame) { if (t.isAlive()) { winner = t; - String time = getFormattedTimeLeft(gameTime - countdown); + String time = getFormattedTimeLeftS(gameTime - countdown); String message = i18nc("team_win", customPrefix) .replace("%team%", TeamColor.fromApiColor(t.getColor()).chatColor + t.getName()) .replace("%time%", time); @@ -2628,10 +2628,17 @@ private String formatScoreboardTitle() { } public String getFormattedTimeLeft() { - return getFormattedTimeLeft(this.countdown); + return getFormattedTimeLeftS(this.countdown); } - public static String getFormattedTimeLeft(int countdown) { + /** + * This method exists to maintain binary compatibility with SBA + */ + public String getFormattedTimeLeft(int countdown) { + return getFormattedTimeLeftS(countdown); + } + + public static String getFormattedTimeLeftS(int countdown) { int min; int sec; String minStr; diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/placeholderapi/BedwarsExpansion.java b/plugin/src/main/java/org/screamingsandals/bedwars/placeholderapi/BedwarsExpansion.java index 7c2f09e15..7d6d0df41 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/placeholderapi/BedwarsExpansion.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/placeholderapi/BedwarsExpansion.java @@ -139,7 +139,7 @@ public String onPlaceholderRequest(Player player, String identifier) { case "time": return Integer.toString(game.getCountdown()); case "timeformat": - return Game.getFormattedTimeLeft(game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getCountdown()); case "elapsedtime": switch (game.getStatus()) { case WAITING: @@ -155,14 +155,14 @@ public String onPlaceholderRequest(Player player, String identifier) { case "elapsedtimeformat": switch (game.getStatus()) { case WAITING: - return Game.getFormattedTimeLeft(game.getLobbyCountdown() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getLobbyCountdown() - game.getCountdown()); case RUNNING: - return Game.getFormattedTimeLeft(game.getGameTime() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getGameTime() - game.getCountdown()); case GAME_END_CELEBRATING: - return Game.getFormattedTimeLeft(game.getPostGameWaiting() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getPostGameWaiting() - game.getCountdown()); case REBUILDING: case DISABLED: - return Game.getFormattedTimeLeft(0); + return Game.getFormattedTimeLeftS(0); } case "world": return game.getWorld().getName(); @@ -326,7 +326,7 @@ public String onPlaceholderRequest(Player player, String identifier) { } case "game_timeformat": if (Main.isPlayerInGame(player)) { - return Game.getFormattedTimeLeft(Main.getPlayerGameProfile(player).getGame().getCountdown()); + return Game.getFormattedTimeLeftS(Main.getPlayerGameProfile(player).getGame().getCountdown()); } else { return "0"; } @@ -352,17 +352,17 @@ public String onPlaceholderRequest(Player player, String identifier) { Game game = Main.getPlayerGameProfile(player).getGame(); switch (game.getStatus()) { case WAITING: - return Game.getFormattedTimeLeft(game.getLobbyCountdown() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getLobbyCountdown() - game.getCountdown()); case RUNNING: - return Game.getFormattedTimeLeft(game.getGameTime() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getGameTime() - game.getCountdown()); case GAME_END_CELEBRATING: - return Game.getFormattedTimeLeft(game.getPostGameWaiting() - game.getCountdown()); + return Game.getFormattedTimeLeftS(game.getPostGameWaiting() - game.getCountdown()); case REBUILDING: case DISABLED: - return Game.getFormattedTimeLeft(0); + return Game.getFormattedTimeLeftS(0); } } else { - return Game.getFormattedTimeLeft(0); + return Game.getFormattedTimeLeftS(0); } case "game_world": if (Main.isPlayerInGame(player)) {