From 9a0b3a41b909c87a061b56f43e3b86933cdd4ea1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 6 Apr 2022 16:59:11 +0200 Subject: [PATCH] Update some stuff --- .../comms/handlers/FightEndsHandler.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java index f86eacf6..03fae605 100644 --- a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java +++ b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java @@ -32,14 +32,18 @@ import java.util.stream.Collectors; public class FightEndsHandler implements SpigotHandler { - private Map> gameModeGames = new HashMap<>(); + private Map> gameModeGames = new HashMap<>(); private int K = 20; + private long defaultFightRange = 1000 /* Milliseconds */ * 60 /* Seconds */ * 15L /* Minutes */; private Map fightRanges = new HashMap<>(); + private long defaultFightCount = 1; + private Map fightCounts = new HashMap<>(); { - fightRanges.put("miniwargear", 1000 /* Milliseconds */ * 60 /* Seconds */ * 10L /* Minutes */); + fightRanges.put("miniwargear", 1000 /* Milliseconds */ * 60 /* Seconds */ * 30L /* Minutes */); + fightCounts.put("miniwargear", 3L); } @Override @@ -73,6 +77,8 @@ public class FightEndsHandler implements SpigotHandler { blueResult = 0; } + // Die nächsten Zeilen filtern ein Fight innerhalb eines Teams nicht gewertet wird, bzw auch wenn nur Teile beider Teams im + // gleichen Team sind dieser ungewertet ist. Set teamsIds = fightEndsPacket.getBluePlayers().stream().map(SteamwarUser::get).map(SteamwarUser::getTeam).collect(Collectors.toSet()); for (int redPlayer : fightEndsPacket.getRedPlayers()) { if (teamsIds.contains(SteamwarUser.get(redPlayer).getTeam())) { @@ -85,7 +91,7 @@ public class FightEndsHandler implements SpigotHandler { return; } } finally { - gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new ArrayList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers())); + gameModeGames.computeIfAbsent(fightEndsPacket.getGameMode(), s -> new LinkedList<>()).add(new Game(fightEndsPacket.getBluePlayers(), fightEndsPacket.getRedPlayers())); } int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem()); @@ -126,7 +132,7 @@ public class FightEndsHandler implements SpigotHandler { List games = gameModeGames.get(gameMode); long lifetime = fightRanges.getOrDefault(gameMode, defaultFightRange); games.removeIf(game -> game.livedMillis() > lifetime); - return games.stream().anyMatch(game -> game.isSame(bluePlayers, redPlayers)); + return games.stream().filter(game -> game.isSame(bluePlayers, redPlayers)).count() > fightCounts.getOrDefault(gameMode, defaultFightCount); } @RequiredArgsConstructor