001 package org.bukkit.event.entity;
002
003 import org.bukkit.entity.Entity;
004 import org.bukkit.entity.LivingEntity;
005 import org.bukkit.entity.Projectile;
006 import org.bukkit.event.Cancellable;
007 import org.bukkit.event.HandlerList;
008 import org.bukkit.inventory.ItemStack;
009
010 /**
011 * Called when a LivingEntity shoots a bow firing an arrow
012 */
013 public class EntityShootBowEvent extends EntityEvent implements Cancellable {
014 private static final HandlerList handlers = new HandlerList();
015 private final ItemStack bow;
016 private Entity projectile;
017 private final float force;
018 private boolean cancelled;
019
020 public EntityShootBowEvent(final LivingEntity shooter, final ItemStack bow, final Projectile projectile, final float force) {
021 super(shooter);
022 this.bow = bow;
023 this.projectile = projectile;
024 this.force = force;
025 }
026
027 @Override
028 public LivingEntity getEntity() {
029 return (LivingEntity) entity;
030 }
031
032 /**
033 * Gets the bow ItemStack used to fire the arrow.
034 *
035 * @return the bow involved in this event
036 */
037 public ItemStack getBow() {
038 return bow;
039 }
040
041 /**
042 * Gets the projectile which will be launched by this event
043 *
044 * @return the launched projectile
045 */
046 public Entity getProjectile() {
047 return projectile;
048 }
049
050 /**
051 * Replaces the projectile which will be launched
052 *
053 * @param projectile the new projectile
054 */
055 public void setProjectile(Entity projectile) {
056 this.projectile = projectile;
057 }
058
059 /**
060 * Gets the force the arrow was launched with
061 *
062 * @return bow shooting force, up to 1.0
063 */
064 public float getForce() {
065 return force;
066 }
067
068 public boolean isCancelled() {
069 return cancelled;
070 }
071
072 public void setCancelled(boolean cancel) {
073 cancelled = cancel;
074 }
075
076 @Override
077 public HandlerList getHandlers() {
078 return handlers;
079 }
080
081 public static HandlerList getHandlerList() {
082 return handlers;
083 }
084 }