[Bleeding] Implement EntityShootBowEvent. Thanks Zeerix.

By: Zeerix <zeerix@draig.de>
This commit is contained in:
CraftBukkit/Spigot 2011-12-28 21:36:02 +01:00
parent c2bf4d0844
commit 6429a4663c

View file

@ -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
*/