diff --git a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java index d54d2390..ee752877 100644 --- a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java +++ b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java @@ -85,7 +85,7 @@ public class FightEndsHandler implements SpigotHandler { private void calculateEloOfTeam(List team, String gameMode, double factor) { for (int player : team) { - int playerElo = UserElo.getElo(player, gameMode).orElse(ELO_DEFAULT); + int playerElo = UserElo.getEloOrDefault(player, gameMode); UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor)); } } diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java index ff49289e..a216673d 100644 --- a/src/de/steamwar/bungeecore/sql/UserElo.java +++ b/src/de/steamwar/bungeecore/sql/UserElo.java @@ -41,6 +41,10 @@ public class UserElo { private static final Statement maxElo = new Statement("SELECT MAX(Elo) AS MaxElo FROM UserElo WHERE Season = ? AND GameMode = ?"); private static final Statement fightsOfSeason = new Statement("SELECT COUNT(*) AS Fights FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID WHERE UserID = ? AND GameMode = ? AND UNIX_TIMESTAMP(StartTime) + Duration >= UNIX_TIMESTAMP(?)"); + public static int getEloOrDefault(int userID, String gameMode) { + return getElo(userID, gameMode).orElse(ELO_DEFAULT); + } + public static Optional getElo(int userID, String gameMode) { return gameModeUserEloCache.computeIfAbsent(gameMode, gm -> { return new HashMap<>();