From edd36519e41b71e19de48ebb0255c4d2d5be9488 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Thu, 12 May 2011 00:52:17 -0500 Subject: [PATCH] Should be a proper fix for "Could not pass event ENTITY_DAMAGE to Factions" exception caused by NPC mods which tie into Player entities --- .../factions/listeners/FactionsEntityListener.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/org/mcteam/factions/listeners/FactionsEntityListener.java b/src/org/mcteam/factions/listeners/FactionsEntityListener.java index 7599d67b..be48c996 100644 --- a/src/org/mcteam/factions/listeners/FactionsEntityListener.java +++ b/src/org/mcteam/factions/listeners/FactionsEntityListener.java @@ -100,17 +100,21 @@ public class FactionsEntityListener extends EntityListener { Entity damagee = sub.getEntity(); int damage = sub.getDamage(); - if ( ! (damagee instanceof Player) || damagee.getLocation() == null) { + if ( ! (damagee instanceof Player)) { return true; } FPlayer defender = FPlayer.get((Player)damagee); + if (defender == null || defender.getPlayer() == null) { + return true; + } + // Players can not take attack damage in a SafeZone if (Board.getFactionAt(new FLocation(defender)).isSafeZone()) { if (damager instanceof Player) { FPlayer attacker = FPlayer.get((Player)damager); - attacker.sendMessage("You cant hurt other players in a SafeZone."); + attacker.sendMessage("You can't hurt other players in a SafeZone."); defender.sendMessage(attacker.getNameAndRelevant(defender)+Conf.colorSystem+" tried to hurt you."); } return false; @@ -121,6 +125,11 @@ public class FactionsEntityListener extends EntityListener { } FPlayer attacker = FPlayer.get((Player)damager); + + if (attacker == null || attacker.getPlayer() == null) { + return true; + } + Relation relation = defender.getRelation(attacker); // Players without faction may be hurt anywhere