From 68ba6a26f7c6c42c8d446ba9c617091078d48b4b Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 11 Mar 2022 13:23:50 +0100 Subject: [PATCH] Update some stuff --- .../steamwar/bungeecore/comms/handlers/FightEndsHandler.java | 4 +++- src/de/steamwar/bungeecore/sql/SchemElo.java | 4 +++- src/de/steamwar/bungeecore/sql/UserElo.java | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java index 86d45fe..d54d239 100644 --- a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java +++ b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java @@ -31,6 +31,8 @@ import net.md_5.bungee.api.config.ServerInfo; import java.util.List; +import static de.steamwar.bungeecore.sql.UserElo.ELO_DEFAULT; + public class FightEndsHandler implements SpigotHandler { private int K = 20; @@ -83,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(1000); + int playerElo = UserElo.getElo(player, gameMode).orElse(ELO_DEFAULT); UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor)); } } diff --git a/src/de/steamwar/bungeecore/sql/SchemElo.java b/src/de/steamwar/bungeecore/sql/SchemElo.java index 5fa8d89..378d2db 100644 --- a/src/de/steamwar/bungeecore/sql/SchemElo.java +++ b/src/de/steamwar/bungeecore/sql/SchemElo.java @@ -19,6 +19,8 @@ package de.steamwar.bungeecore.sql; +import static de.steamwar.bungeecore.sql.UserElo.ELO_DEFAULT; + public class SchemElo { private SchemElo() {} @@ -33,7 +35,7 @@ public class SchemElo { return elo.select(rs -> { if (rs.next()) return rs.getInt("Elo"); - return 1000; + return ELO_DEFAULT; }, schemID, season); } diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java index ddeae96..8593cae 100644 --- a/src/de/steamwar/bungeecore/sql/UserElo.java +++ b/src/de/steamwar/bungeecore/sql/UserElo.java @@ -31,6 +31,8 @@ public class UserElo { private UserElo() { } + public static final int ELO_DEFAULT = 1000; + private static final Map> userEloCache = new HashMap<>(); private static final Map maxEloCache = new HashMap<>(); private static final Map emblemCache = new HashMap<>();