From fe7ca65f2223ee6c33c7fbf48e6ceb8142794f79 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 2 Mar 2012 16:53:35 -0800 Subject: [PATCH] dealDamage() will now send fake EntityDamageEvent which mcMMO will ignore --- src/main/java/com/gmail/nossr50/Combat.java | 3 ++- .../java/com/gmail/nossr50/listeners/mcEntityListener.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index 2b0ff52d8..e810c0659 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -27,6 +27,7 @@ import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent; +import com.gmail.nossr50.events.FakeEntityDamageEvent; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.Acrobatics; @@ -296,7 +297,7 @@ public class Combat */ public static void dealDamage(LivingEntity target, int dmg, DamageCause cause) { if(LoadProperties.eventCallback) { - EntityDamageEvent ede = new EntityDamageEvent(target, cause, dmg); + EntityDamageEvent ede = (EntityDamageEvent) new FakeEntityDamageEvent(target, cause, dmg); Bukkit.getPluginManager().callEvent(ede); if(ede.isCancelled()) return; diff --git a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java index 6bbfc1230..337a58745 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcEntityListener.java @@ -47,6 +47,7 @@ import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent; +import com.gmail.nossr50.events.FakeEntityDamageEvent; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.skills.Acrobatics; import com.gmail.nossr50.skills.Archery; @@ -93,6 +94,9 @@ public class mcEntityListener implements Listener @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { + if(event instanceof FakeEntityDamageEvent) + return; + Entity entity = event.getEntity(); EntityType type = entity.getType(); DamageCause cause = event.getCause();