From bcf6440bc42fcc80c0ec3b08c79f8d501f464749 Mon Sep 17 00:00:00 2001 From: Zeerix Date: Wed, 28 Dec 2011 21:36:02 +0100 Subject: [Bleeding] Implement EntityShootBowEvent. Thanks Zeerix. --- .../bukkit/craftbukkit/event/CraftEventFactory.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index cc1518b3..955d1a90 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -5,6 +5,7 @@ import java.util.List; import net.minecraft.server.ChunkCoordinates; import net.minecraft.server.Entity; +import net.minecraft.server.EntityArrow; import net.minecraft.server.EntityBlaze; import net.minecraft.server.EntityCaveSpider; import net.minecraft.server.EntityChicken; @@ -51,7 +52,9 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.AnimalTamer; +import org.bukkit.entity.Arrow; import org.bukkit.entity.CreatureType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Event.Type; import org.bukkit.event.block.*; @@ -182,6 +185,24 @@ public class CraftEventFactory { return event; } + /** + * EntityShootBowEvent + */ + public static EntityShootBowEvent callEntityShootBowEvent(EntityLiving who, ItemStack itemstack, EntityArrow entityArrow, float force) { + LivingEntity shooter = (LivingEntity) who.getBukkitEntity(); + CraftItemStack itemInHand = new CraftItemStack(itemstack); + Arrow arrow = (Arrow) entityArrow.getBukkitEntity(); + + if (itemInHand != null && (itemInHand.getType() == Material.AIR || itemInHand.getAmount() == 0)) { + itemInHand = null; + } + + EntityShootBowEvent event = new EntityShootBowEvent(shooter, itemInHand, arrow, force); + Bukkit.getPluginManager().callEvent(event); + + return event; + } + /** * BlockDamageEvent */ -- cgit v1.2.3