Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/LastStandStatTracker.java

65 lines
1.6 KiB
Java
Raw Normal View History

2014-08-21 01:20:11 +02:00
package nautilus.game.arcade.stats;
import java.util.HashMap;
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;
2014-08-25 22:27:02 +02:00
import nautilus.game.arcade.game.Game;
2014-08-21 01:20:11 +02:00
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead;
public class LastStandStatTracker extends StatTracker<TeamGame>
{
private final Map<UUID, Integer> _kills = new HashMap<>();
public LastStandStatTracker(TeamGame game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
2014-08-25 22:27:02 +02:00
if (getGame().GetState() != Game.GameState.Live)
return;
2014-08-21 01:20:11 +02:00
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;
if (getGame().GetTeam(killer).GetPlayers(true).size() == 1)
{
Integer kills = _kills.get(killer.getUniqueId());
kills = (kills == null ? 0 : kills) + 1;
_kills.put(killer.getUniqueId(), kills);
if (kills >= 3)
getGame().AddStat(killer, "LastStand", 1, true, false);
}
}
}