Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/ClutchStatTracker.java
AlexTheCoder 7c04e5608d - Added new achievement 'Clutch'
- Made new achievements needed for achievement skills
2015-09-25 04:17:20 -04:00

57 lines
1.3 KiB
Java

package nautilus.game.arcade.stats;
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.games.common.CaptureTheFlag;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
public class ClutchStatTracker extends StatTracker<CaptureTheFlag>
{
private final String _stat;
public ClutchStatTracker(CaptureTheFlag game, String stat)
{
super(game);
_stat = stat;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
if (getGame().GetState() != Game.GameState.Live)
return;
if (!getGame().isSuddenDeath())
return;
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (player == null)
return;
Player killed = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if (killed == null)
return;
if (!getGame().isEnemyCarrier(killed, player))
return;
addStat(player, getStat(), 1, false, false);
}
public String getStat()
{
return _stat;
}
}