Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/TeamDeathsStatTracker.java
2014-08-25 18:06:50 -04:00

44 lines
1.1 KiB
Java

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;
public class TeamDeathsStatTracker extends StatTracker<Game>
{
public TeamDeathsStatTracker(Game game)
{
super(game);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
if (getGame().GetTeamList().size() < 2)
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;
GameTeam team = getGame().GetTeam(player);
if (team != null && team.GetName() != null)
getGame().AddStat(player, team.GetName() + " Deaths", 1, false, false);
}
}