From 92c0e58590000fc12fe844dcec00c74fb98503fb Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 14 Mar 2022 20:05:16 +0100 Subject: [PATCH] Update UserElo --- src/de/steamwar/bungeecore/sql/UserElo.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/bungeecore/sql/UserElo.java b/src/de/steamwar/bungeecore/sql/UserElo.java index be2fb1b..3f937f7 100644 --- a/src/de/steamwar/bungeecore/sql/UserElo.java +++ b/src/de/steamwar/bungeecore/sql/UserElo.java @@ -24,7 +24,6 @@ import de.steamwar.bungeecore.ArenaMode; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; public class UserElo { private UserElo() { @@ -79,18 +78,14 @@ public class UserElo { public static void setElo(int userId, String gameMode, int elo) { emblemCache.remove(userId); Optional previousElo = gameModeUserEloCache.computeIfAbsent(gameMode, gm -> new HashMap<>()).put(userId, Optional.of(elo)); - AtomicBoolean invalidate = new AtomicBoolean(false); - maxEloCache.compute(gameMode, (gm, max) -> { + int newElo = maxEloCache.compute(gameMode, (gm, max) -> { if (max == null || max < elo) { emblemCache.clear(); return elo; } - if (previousElo != null && previousElo.isPresent() && previousElo.get() == (int) max) { - invalidate.set(true); - } return max; }); - if (invalidate.get()) { + if (previousElo != null && previousElo.isPresent() && previousElo.get() == newElo) { maxEloCache.remove(gameMode); emblemCache.clear(); }