diff options
author | Andre LeBlanc <andre@norcode.com> | 2013-03-23 12:16:00 -0400 |
---|---|---|
committer | GJ <gjmcferrin@gmail.com> | 2013-03-26 07:13:14 -0400 |
commit | 08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb (patch) | |
tree | e3b39591166d5642b7c2f084f16eb872ba768cee /src | |
parent | 45d3e2514dc3dbe6d7b103cc19fe945111263bb7 (diff) | |
download | craftbukkit-08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb.tar craftbukkit-08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb.tar.gz craftbukkit-08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb.tar.lz craftbukkit-08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb.tar.xz craftbukkit-08f3df82eb4a6002fc2d7972dfb9a09243bf7bbb.zip |
Improve calling of ProjectileHitEvent. Fixes BUKKIT-3872
Diffstat (limited to 'src')
5 files changed, 10 insertions, 15 deletions
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 2c0f689a..f46c9209 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -3,9 +3,7 @@ package net.minecraft.server; import java.util.List; // CraftBukkit start -import org.bukkit.entity.Projectile; import org.bukkit.event.entity.EntityCombustByEntityEvent; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.player.PlayerPickupItemEvent; // CraftBukkit end @@ -209,11 +207,7 @@ public class EntityArrow extends Entity implements IProjectile { float f3; if (movingobjectposition != null) { - // CraftBukkit start - Projectile projectile = (Projectile) this.getBukkitEntity(); - ProjectileHitEvent phe = new ProjectileHitEvent(projectile); - this.world.getServer().getPluginManager().callEvent(phe); - // CraftBukkit end + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event if (movingobjectposition.entity != null) { f2 = MathHelper.sqrt(this.motX * this.motX + this.motY * this.motY + this.motZ * this.motZ); diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 84da8cba..194a58fc 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -2,8 +2,6 @@ package net.minecraft.server; import java.util.List; -import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit - public abstract class EntityFireball extends Entity { private int e = -1; @@ -133,8 +131,7 @@ public abstract class EntityFireball extends Entity { // CraftBukkit start if (this.dead) { - ProjectileHitEvent phe = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity()); - this.world.getServer().getPluginManager().callEvent(phe); + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/server/EntityFishingHook.java b/src/main/java/net/minecraft/server/EntityFishingHook.java index b35a5d65..a3bb5d0d 100644 --- a/src/main/java/net/minecraft/server/EntityFishingHook.java +++ b/src/main/java/net/minecraft/server/EntityFishingHook.java @@ -178,6 +178,7 @@ public class EntityFishingHook extends Entity { } if (movingobjectposition != null) { + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event if (movingobjectposition.entity != null) { if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0)) { this.hooked = movingobjectposition.entity; diff --git a/src/main/java/net/minecraft/server/EntityProjectile.java b/src/main/java/net/minecraft/server/EntityProjectile.java index 85ca93d3..2ab11b3c 100644 --- a/src/main/java/net/minecraft/server/EntityProjectile.java +++ b/src/main/java/net/minecraft/server/EntityProjectile.java @@ -2,8 +2,6 @@ package net.minecraft.server; import java.util.List; -import org.bukkit.event.entity.ProjectileHitEvent; // CraftBukkit - public abstract class EntityProjectile extends Entity implements IProjectile { private int blockX = -1; @@ -158,8 +156,7 @@ public abstract class EntityProjectile extends Entity implements IProjectile { this.a(movingobjectposition); // CraftBukkit start if (this.dead) { - ProjectileHitEvent hitEvent = new ProjectileHitEvent((org.bukkit.entity.Projectile) this.getBukkitEntity()); - org.bukkit.Bukkit.getPluginManager().callEvent(hitEvent); + org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); } // CraftBukkit end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 34942327..f65b7f85 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -532,6 +532,12 @@ public class CraftEventFactory { return event; } + public static ProjectileHitEvent callProjectileHitEvent(Entity entity) { + ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity()); + entity.world.getServer().getPluginManager().callEvent(event); + return event; + } + public static ExpBottleEvent callExpBottleEvent(Entity entity, int exp) { ThrownExpBottle bottle = (ThrownExpBottle) entity.getBukkitEntity(); ExpBottleEvent event = new ExpBottleEvent(bottle, exp); |