Mineplex2018-withcommit/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/DeathBomberStatTracker.java

70 lines
1.7 KiB
Java
Raw Normal View History

2014-08-20 03:16:28 +02:00
package nautilus.game.arcade.stats;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import nautilus.game.arcade.game.Game;
public class DeathBomberStatTracker extends StatTracker<Game>
{
2015-06-26 07:57:47 +02:00
private int _required;
2014-08-20 03:16:28 +02:00
private final Map<UUID, Integer> _killCount = new HashMap<>();
2015-06-26 07:57:47 +02:00
public DeathBomberStatTracker(Game game, int requiredKills)
2014-08-20 03:16:28 +02:00
{
super(game);
2015-06-26 07:57:47 +02:00
_required = requiredKills;
2014-08-20 03:16:28 +02:00
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCombatDeath(CombatDeathEvent event)
{
2014-08-25 22:27:02 +02:00
if (getGame().GetState() != Game.GameState.Live)
return;
2014-08-20 03:16:28 +02:00
if (event.GetLog().GetKiller() == null)
return;
if (!event.GetLog().GetKiller().IsPlayer())
return;
Player killer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
if (killer == null)
return;
if (event.GetLog().GetPlayer() == null)
return;
if (!event.GetLog().GetPlayer().IsPlayer())
return;
Player killed = UtilPlayer.searchExact(event.GetLog().GetPlayer().GetName());
if(killer.equals(killed))
return;
2014-08-20 03:16:28 +02:00
2014-11-01 01:25:08 +01:00
if (event.GetLog().GetKiller() != null && event.GetLog().GetKiller().GetReason().contains("Throwing TNT"))
2014-08-20 03:16:28 +02:00
{
Integer count = _killCount.get(killer.getUniqueId());
count = (count == null ? 0 : count) + 1;
2014-11-01 01:25:08 +01:00
System.out.println("Death Bomber: " + killer.getName() + " " + count);
2014-08-20 03:16:28 +02:00
_killCount.put(killer.getUniqueId(), count);
2015-06-26 07:57:47 +02:00
if (count >= _required)
addStat(killer, "DeathBomber", 1, true, false);
2014-08-20 03:16:28 +02:00
}
}
}