From b5a1151178bacfadeb322671f48a334b5771a495 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Thu, 8 Sep 2011 03:20:55 -0500 Subject: [PATCH] fix for arrow damage not being properly detected and prevented (when needed) which was broken by Bukkit's recent deprecation of EntityDamageByProjectileEvent --- .../factions/listeners/FactionsEntityListener.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 5cfb6621..4f22ff2c 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -8,9 +8,9 @@ import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityExplodeEvent; @@ -81,11 +81,6 @@ public class FactionsEntityListener extends EntityListener { if ( ! this.canDamagerHurtDamagee(sub)) { event.setCancelled(true); } - } else if (event instanceof EntityDamageByProjectileEvent) { - EntityDamageByProjectileEvent sub = (EntityDamageByProjectileEvent)event; - if ( ! this.canDamagerHurtDamagee(sub)) { - event.setCancelled(true); - } } else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { // Players can not take any damage in a Safe Zone event.setCancelled(true); @@ -167,7 +162,12 @@ public class FactionsEntityListener extends EntityListener { } Faction defLocFaction = Board.getFactionAt(new FLocation(defenderLoc)); - + + // for damage caused by projectiles, getDamager() returns the projectile... what we need to know is the source + if (damager instanceof Projectile) { + damager = ((Projectile)damager).getShooter(); + } + // Players can not take attack damage in a SafeZone, or possibly peaceful territory if (defLocFaction.noPvPInTerritory()) { if (damager instanceof Player) {