7c04e5608d
- Made new achievements needed for achievement skills
57 lines
1.3 KiB
Java
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;
|
|
}
|
|
|
|
}
|