fix for arrow damage not being properly detected and prevented (when needed) which was broken by Bukkit's recent deprecation of EntityDamageByProjectileEvent

This commit is contained in:
Brettflan 2011-09-08 03:20:55 -05:00
parent c89db2c4d6
commit b5a1151178

View File

@ -8,9 +8,9 @@ import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
@ -81,11 +81,6 @@ public class FactionsEntityListener extends EntityListener {
if ( ! this.canDamagerHurtDamagee(sub)) { if ( ! this.canDamagerHurtDamagee(sub)) {
event.setCancelled(true); 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())) { } else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) {
// Players can not take any damage in a Safe Zone // Players can not take any damage in a Safe Zone
event.setCancelled(true); event.setCancelled(true);
@ -168,6 +163,11 @@ public class FactionsEntityListener extends EntityListener {
Faction defLocFaction = Board.getFactionAt(new FLocation(defenderLoc)); 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 // Players can not take attack damage in a SafeZone, or possibly peaceful territory
if (defLocFaction.noPvPInTerritory()) { if (defLocFaction.noPvPInTerritory()) {
if (damager instanceof Player) { if (damager instanceof Player) {