From 8ada9a6335e39bcffb11105415009d80e168ae84 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Mon, 10 Nov 2025 11:01:31 +0100 Subject: [PATCH] Fix UserElo.getEloFromDb --- CommonCore/SQL/src/de/steamwar/sql/Season.java | 4 ++-- CommonCore/SQL/src/de/steamwar/sql/UserElo.kt | 2 +- .../src/de/steamwar/messages/BungeeCore.properties | 3 ++- .../src/de/steamwar/messages/BungeeCore_de.properties | 3 ++- .../src/de/steamwar/velocitycore/commands/RankCommand.java | 7 +++---- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/Season.java b/CommonCore/SQL/src/de/steamwar/sql/Season.java index f366cbdb..588717a5 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/Season.java +++ b/CommonCore/SQL/src/de/steamwar/sql/Season.java @@ -46,14 +46,14 @@ public class Season { if (season == -1) return ""; int yearSeason = season % 3; int year = (season - yearSeason) / 3; - return String.format("%d-%d", year, yearSeason); + return String.format("%d-%d", year, yearSeason + 1); } public static int convertSeasonToNumber(String season){ if (season.isEmpty()) return -1; String[] split = season.split("-"); try { - return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]); + return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]) - 1; } catch (NumberFormatException e) { return -1; } diff --git a/CommonCore/SQL/src/de/steamwar/sql/UserElo.kt b/CommonCore/SQL/src/de/steamwar/sql/UserElo.kt index 31b1b34a..84441f46 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/UserElo.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/UserElo.kt @@ -67,7 +67,7 @@ class UserElo(id: EntityID) : CompositeEntity(id) { .getOrPut(userId) { getEloFromDb(userId, gameMode)?.elo } private fun getEloFromDb(userId: Int, gameMode: String) = useDb { - find { (UserEloTable.userId eq userId) and (UserEloTable.gameMode eq gameMode) }.firstOrNull() + find { (UserEloTable.userId eq userId) and (UserEloTable.gameMode eq gameMode) and (UserEloTable.season eq Season.getSeason()) }.firstOrNull() } @JvmStatic diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties index 5677b367..2b7ec0d1 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore.properties @@ -677,7 +677,8 @@ ARENA_NOT_FOUND=§cThe specified arena could not be found #Rank RANK_PLAYER_NOT_FOUND=§cPlayer not found RANK_PLAYER_FOUND=§eRank §7of §e{0} -RANK_HEADER={0} §e{1} {2} +RANK_HEADER=§eRank Season {0} +RANK_DATA={0} §e{1} {2} RANK_UNPLACED=§7unranked RANK_PLACED=§e{0}§8. §7with §e{1} §7Elo§8. diff --git a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties index 82005c6d..1e901782 100644 --- a/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties +++ b/VelocityCore/src/de/steamwar/messages/BungeeCore_de.properties @@ -644,7 +644,8 @@ ARENA_NOT_FOUND=§cDie angegebene Arena konnte nicht gefunden werden #Rank RANK_PLAYER_NOT_FOUND=§cSpieler nicht gefunden RANK_PLAYER_FOUND=§eRang §7von §e{0} -RANK_HEADER={0} §e{1} {2} +RANK_HEADER=§eRang Saison {0} +RANK_DATA={0} §e{1} {2} RANK_UNPLACED=§7unplatziert RANK_PLACED=§e{0}§8. §7mit §e{1} §7Elo§8. diff --git a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java index 49ac0a9e..92579cb4 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java +++ b/VelocityCore/src/de/steamwar/velocitycore/commands/RankCommand.java @@ -24,13 +24,11 @@ import de.steamwar.sql.GameModeConfig; import de.steamwar.linkage.Linked; import de.steamwar.messages.Chatter; import de.steamwar.messages.Message; -import de.steamwar.sql.SchematicType; +import de.steamwar.sql.Season; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserElo; import de.steamwar.velocitycore.ArenaMode; -import java.util.Optional; - @Linked public class RankCommand extends SWCommand { @@ -45,6 +43,7 @@ public class RankCommand extends SWCommand { @Register public void rank(Chatter sender, @ErrorMessage("RANK_PLAYER_NOT_FOUND") SteamwarUser user) { + sender.prefixless("RANK_HEADER", Season.convertSeasonToString(Season.getSeason())); if (!sender.user().equals(user)) sender.prefixless("RANK_PLAYER_FOUND", user); @@ -61,7 +60,7 @@ public class RankCommand extends SWCommand { eloMsg = new Message("RANK_UNPLACED"); } - sender.prefixless("RANK_HEADER", UserElo.getEmblemProgression(mode.getChatName(), user.getId()), mode.getChatName(), eloMsg); + sender.prefixless("RANK_DATA", UserElo.getEmblemProgression(mode.getChatName(), user.getId()), mode.getChatName(), eloMsg); } } }