Skip to content

Commit

Permalink
fix: fixed binary compatibility issue in addons
Browse files Browse the repository at this point in the history
particularly fixed SBA expecting non-static getFormattedTimeLeft(int) method
  • Loading branch information
Misat11 committed Apr 24, 2024
1 parent 5aa2dbb commit fe56e24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
13 changes: 10 additions & 3 deletions plugin/src/main/java/org/screamingsandals/bedwars/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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();
Expand Down Expand Up @@ -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";
}
Expand All @@ -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)) {
Expand Down

0 comments on commit fe56e24

Please sign in to comment.