2014-08-25 23:43:49 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
|
|
|
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.game.Game;
|
|
|
|
import nautilus.game.arcade.game.GameTeam;
|
|
|
|
|
2014-08-26 00:06:50 +02:00
|
|
|
public class TeamKillsStatTracker extends StatTracker<Game>
|
2014-08-25 23:43:49 +02:00
|
|
|
{
|
2014-08-26 00:06:50 +02:00
|
|
|
public TeamKillsStatTracker(Game game)
|
2014-08-25 23:43:49 +02:00
|
|
|
{
|
|
|
|
super(game);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
|
|
|
public void onCombatDeath(CombatDeathEvent event)
|
|
|
|
{
|
|
|
|
if (getGame().GetState() != Game.GameState.Live)
|
|
|
|
return;
|
|
|
|
|
2014-08-26 00:06:50 +02:00
|
|
|
if (getGame().GetTeamList().size() < 2)
|
|
|
|
return;
|
|
|
|
|
2014-08-25 23:43:49 +02:00
|
|
|
if (event.GetLog().GetKiller() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!event.GetLog().GetKiller().IsPlayer())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
|
|
|
if (player == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GameTeam team = getGame().GetTeam(player);
|
|
|
|
|
|
|
|
if (team != null && team.GetName() != null)
|
2014-08-26 22:30:55 +02:00
|
|
|
addStat(player, team.GetName() + " Kills", 1, false, false);
|
2014-08-25 23:43:49 +02:00
|
|
|
}
|
|
|
|
}
|