diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index cc1518b342..955d1a904d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/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 */