diff options
author | feildmaster <admin@feildmaster.com> | 2012-03-25 04:21:25 -0500 |
---|---|---|
committer | Warren Loo <evilseph@gmail.com> | 2012-03-26 16:05:38 -0400 |
commit | 9d0ea520213227a39e346571c7c502f7a3a241c7 (patch) | |
tree | d58f8cf547c301cbc12f4e287efb8c9e388c8430 | |
parent | b45184fdf8f08a86b67c062eee8483254c93cdff (diff) | |
download | craftbukkit-9d0ea520213227a39e346571c7c502f7a3a241c7.tar craftbukkit-9d0ea520213227a39e346571c7c502f7a3a241c7.tar.gz craftbukkit-9d0ea520213227a39e346571c7c502f7a3a241c7.tar.lz craftbukkit-9d0ea520213227a39e346571c7c502f7a3a241c7.tar.xz craftbukkit-9d0ea520213227a39e346571c7c502f7a3a241c7.zip |
[Bleeding] Fixed potions throwing double events. Fixes BUKKIT-1332
-rw-r--r-- | src/main/java/net/minecraft/server/MobEffectList.java | 16 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java | 11 |
2 files changed, 10 insertions, 17 deletions
diff --git a/src/main/java/net/minecraft/server/MobEffectList.java b/src/main/java/net/minecraft/server/MobEffectList.java index 3b69deb9..78945bbc 100644 --- a/src/main/java/net/minecraft/server/MobEffectList.java +++ b/src/main/java/net/minecraft/server/MobEffectList.java @@ -1,13 +1,12 @@ package net.minecraft.server; // CraftBukkit start -import org.bukkit.Bukkit; -import org.bukkit.potion.PotionEffectType; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.potion.PotionEffectType; // CraftBukkit end public class MobEffectList { @@ -86,7 +85,6 @@ public class MobEffectList { if (entityliving.getHealth() > 1) { // CraftBukkit start EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, DamageCause.POISON, 1); - Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled() && event.getDamage() > 0) { entityliving.damageEntity(DamageSource.MAGIC, event.getDamage()); @@ -99,7 +97,6 @@ public class MobEffectList { if (this.id == HARM.id && !entityliving.aN() || this.id == HEAL.id && entityliving.aN()) { // CraftBukkit start EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(null, entityliving, DamageCause.MAGIC, 6 << i); - Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled() && event.getDamage() > 0) { entityliving.damageEntity(DamageSource.MAGIC, event.getDamage()); @@ -124,18 +121,11 @@ public class MobEffectList { if (this.id == HARM.id && !entityliving1.aN() || this.id == HEAL.id && entityliving1.aN()) { j = (int) (d0 * (double) (6 << i) + 0.5D); - // CraftBukkit start - EntityDamageEvent event = CraftEventFactory.callEntityDamageEvent(potion != null ? potion : entityliving, entityliving1, DamageCause.MAGIC, j); - j = event.getDamage(); - if (event.isCancelled() || j == 0) { - return; - } - // CraftBukkit end - if (entityliving == null) { entityliving1.damageEntity(DamageSource.MAGIC, j); } else { - entityliving1.damageEntity(DamageSource.b(entityliving1, entityliving), j); + // CraftBukkit - The "damager" needs to be the potion + entityliving1.damageEntity(DamageSource.b(potion != null ? potion : entityliving1, entityliving), j); } } } else { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 91b60add..bee08c37 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -364,14 +364,17 @@ public class CraftEventFactory { public static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, int damage) { Entity damager = source.getEntity(); - EntityDamageEvent.DamageCause cause = EntityDamageEvent.DamageCause.ENTITY_ATTACK; + DamageCause cause = DamageCause.ENTITY_ATTACK; if (source instanceof EntityDamageSourceIndirect) { damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource(); - if (damager.getBukkitEntity() instanceof Projectile) { - cause = EntityDamageEvent.DamageCause.PROJECTILE; - } // Else, magic..? + if (damager.getBukkitEntity() instanceof ThrownPotion) { + cause = DamageCause.MAGIC; + } else if (damager.getBukkitEntity() instanceof Projectile) { + cause = DamageCause.PROJECTILE; + } } + return callEntityDamageEvent(damager, entity, cause, damage); } |