From 38774b583f436bf3d2e89b9a36694ee6bb68e6c3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 8 Feb 2012 18:05:44 +0100 Subject: [PATCH] A huge flaw on my side --- src/main/java/com/gmail/nossr50/Combat.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index 8d57deea2..8055e5da2 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -395,13 +395,17 @@ public class Combat * @param attacker Entity to pass to event as damager */ public static void dealDamage(LivingEntity target, int dmg, DamageCause cause, Entity attacker) { - EntityDamageEvent ede = new EntityDamageByEntityEvent(attacker, target, cause, dmg); - Bukkit.getPluginManager().callEvent(ede); - target.damage(ede.getDamage()); + EntityDamageEvent event; + if (attacker == null) { + event = new EntityDamageEvent(target, cause, dmg); + } else { + event = new EntityDamageByEntityEvent(attacker, target, cause, dmg); + } + Bukkit.getPluginManager().callEvent(event); + target.damage(event.getDamage()); } - public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world) - { + public static boolean pvpAllowed(EntityDamageByEntityEvent event, World world) { if(!((world == null)?event.getEntity().getWorld():world).getPVP()) { return false; } //If it made it this far, pvp is enabled return true;