SteamWar/BungeeCore
Archiviert
13
2

Update UserElo
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-14 20:05:16 +01:00
Ursprung af978cab2b
Commit 92c0e58590

Datei anzeigen

@ -24,7 +24,6 @@ import de.steamwar.bungeecore.ArenaMode;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
public class UserElo { public class UserElo {
private UserElo() { private UserElo() {
@ -79,18 +78,14 @@ public class UserElo {
public static void setElo(int userId, String gameMode, int elo) { public static void setElo(int userId, String gameMode, int elo) {
emblemCache.remove(userId); emblemCache.remove(userId);
Optional<Integer> previousElo = gameModeUserEloCache.computeIfAbsent(gameMode, gm -> new HashMap<>()).put(userId, Optional.of(elo)); Optional<Integer> previousElo = gameModeUserEloCache.computeIfAbsent(gameMode, gm -> new HashMap<>()).put(userId, Optional.of(elo));
AtomicBoolean invalidate = new AtomicBoolean(false); int newElo = maxEloCache.compute(gameMode, (gm, max) -> {
maxEloCache.compute(gameMode, (gm, max) -> {
if (max == null || max < elo) { if (max == null || max < elo) {
emblemCache.clear(); emblemCache.clear();
return elo; return elo;
} }
if (previousElo != null && previousElo.isPresent() && previousElo.get() == (int) max) {
invalidate.set(true);
}
return max; return max;
}); });
if (invalidate.get()) { if (previousElo != null && previousElo.isPresent() && previousElo.get() == newElo) {
maxEloCache.remove(gameMode); maxEloCache.remove(gameMode);
emblemCache.clear(); emblemCache.clear();
} }