This commit is contained in:
Mysticate 2015-08-28 21:35:31 -06:00
parent 815add4c59
commit 4466c10441

View File

@ -0,0 +1,60 @@
package nautilus.game.arcade.game.games.evolution.trackers;
import java.util.ArrayList;
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.GameState;
import nautilus.game.arcade.game.games.evolution.Evolution;
import nautilus.game.arcade.stats.StatTracker;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class EvoWinWithoutDyingTracker extends StatTracker<Evolution>
{
private ArrayList<String> _out = new ArrayList<String>();
public EvoWinWithoutDyingTracker(Evolution evo)
{
super(evo);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (!getGame().IsLive())
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (player == null || !player.isOnline())
{
return;
}
_out.add(player.getName());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onGameStateChange(GameStateChangeEvent event)
{
if (event.GetState() != GameState.End)
return;
if (getGame().Winner == null)
return;
if (_out.contains(getGame().Winner.getName()))
return;
addStat(getGame().Winner, "NoDeaths", 1, true, false);
}
}