2014-10-11 03:49:03 +02:00
|
|
|
package nautilus.game.arcade.stats;
|
|
|
|
|
2014-10-14 02:38:58 +02:00
|
|
|
import org.bukkit.entity.EntityType;
|
2014-10-11 03:49:03 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Projectile;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
|
|
|
|
2014-11-04 09:17:06 +01:00
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
2014-10-11 03:49:03 +02:00
|
|
|
import nautilus.game.arcade.game.Game;
|
|
|
|
|
2014-10-14 02:38:58 +02:00
|
|
|
public class KillEntityStatTracker extends StatTracker<Game>
|
2014-10-11 03:49:03 +02:00
|
|
|
{
|
|
|
|
private final String _statName;
|
2014-10-14 02:38:58 +02:00
|
|
|
private EntityType _entityType;
|
2014-10-11 03:49:03 +02:00
|
|
|
|
2014-10-14 02:38:58 +02:00
|
|
|
public KillEntityStatTracker(Game game, String statName, EntityType entityType)
|
2014-10-11 03:49:03 +02:00
|
|
|
{
|
|
|
|
super(game);
|
|
|
|
|
|
|
|
_statName = statName;
|
2014-10-14 02:38:58 +02:00
|
|
|
setEntityType(entityType);
|
2014-10-11 03:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
2014-11-04 09:17:06 +01:00
|
|
|
public void onKillingBlow(CustomDamageEvent event)
|
2014-10-11 03:49:03 +02:00
|
|
|
{
|
2014-11-04 09:17:06 +01:00
|
|
|
if (event.GetDamageeEntity().getType() != getEntityType())
|
2014-10-11 03:49:03 +02:00
|
|
|
return;
|
|
|
|
|
2014-11-04 09:17:06 +01:00
|
|
|
if (!event.GetDamageeEntity().isDead())
|
2014-10-11 03:49:03 +02:00
|
|
|
return;
|
2014-11-04 09:17:06 +01:00
|
|
|
|
|
|
|
Player player = event.GetDamagerPlayer(true);
|
|
|
|
if (player == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
addStat(player, getStatName(), 1, false, false);
|
2014-10-11 03:49:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getStatName()
|
|
|
|
{
|
|
|
|
return _statName;
|
|
|
|
}
|
2014-10-14 02:38:58 +02:00
|
|
|
|
|
|
|
public EntityType getEntityType()
|
|
|
|
{
|
|
|
|
return _entityType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEntityType(EntityType entityType)
|
|
|
|
{
|
|
|
|
_entityType = entityType;
|
|
|
|
}
|
2014-10-11 03:49:03 +02:00
|
|
|
}
|