geforkt von SteamWar/BungeeCore
Update UserElo
Dieser Commit ist enthalten in:
Ursprung
af978cab2b
Commit
92c0e58590
@ -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<Integer> 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();
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren