package nautilus.game.arcade.stats; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; public class OneVThreeStatTracker extends StatTracker { private final Map _killCount = new HashMap<>(); public OneVThreeStatTracker(Game game) { super(game); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCombatDeath(CombatDeathEvent event) { if (getGame().GetState() != Game.GameState.Live) return; if (event.GetLog().GetKiller() == null) return; if (!event.GetLog().GetKiller().IsPlayer()) return; Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); if (killer == null) return; if (event.GetLog().GetPlayer() == null) return; if (!event.GetLog().GetPlayer().IsPlayer()) return; Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName()); if (player == null) return; Integer killCount = _killCount.get(killer.getUniqueId()); if (killCount == null) killCount = 0; killCount++; _killCount.put(killer.getUniqueId(), killCount); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onGameStateChange(GameStateChangeEvent event) { if (event.GetState() == Game.GameState.End) { List players = getGame().GetPlayers(false); if (players.size() >= 4) return; for (Player player : players) { Integer killCount = _killCount.get(player.getUniqueId()); if (killCount != null && killCount >= 10) getGame().AddStat(player, "1v3", 1, true, false); } } } }