82 lines
2.0 KiB
Java
82 lines
2.0 KiB
Java
package org.bukkit.event.entity;
|
|
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.LivingEntity;
|
|
import org.bukkit.entity.Projectile;
|
|
import org.bukkit.event.Cancellable;
|
|
import org.bukkit.event.HandlerList;
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
/**
|
|
* Called when a LivingEntity shoots a bow firing an arrow
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
public class EntityShootBowEvent extends EntityEvent implements Cancellable {
|
|
private static final HandlerList handlers = new HandlerList();
|
|
|
|
private ItemStack bow;
|
|
private Entity projectile;
|
|
private float force;
|
|
private boolean cancelled;
|
|
|
|
public EntityShootBowEvent(LivingEntity shooter, ItemStack bow, Projectile projectile, float force) {
|
|
super(Type.ENTITY_SHOOT_BOW, shooter);
|
|
this.bow = bow;
|
|
this.projectile = projectile;
|
|
this.force = force;
|
|
}
|
|
|
|
/**
|
|
* Gets the bow ItemStack used to fire the arrow; is null if the shooter is a skeleton
|
|
*
|
|
* @return the bow involved in this event, or null
|
|
*/
|
|
public ItemStack getBow() {
|
|
return bow;
|
|
}
|
|
|
|
/**
|
|
* Gets the projectile which will be launched by this event
|
|
*
|
|
* @return the launched projectile
|
|
*/
|
|
public Entity getProjectile() {
|
|
return projectile;
|
|
}
|
|
|
|
/**
|
|
* Replaces the projectile which will be launched
|
|
*
|
|
* @param projectile the new projectile
|
|
*/
|
|
public void setProjectile(Entity projectile) {
|
|
this.projectile = projectile;
|
|
}
|
|
|
|
/**
|
|
* Gets the force the arrow was launched with
|
|
*
|
|
* @return bow shooting force, up to 1.0
|
|
*/
|
|
public float getForce() {
|
|
return force;
|
|
}
|
|
|
|
public boolean isCancelled() {
|
|
return cancelled;
|
|
}
|
|
|
|
public void setCancelled(boolean cancel) {
|
|
cancelled = cancel;
|
|
}
|
|
|
|
@Override
|
|
public HandlerList getHandlers() {
|
|
return handlers;
|
|
}
|
|
|
|
public static HandlerList getHandlerList() {
|
|
return handlers;
|
|
}
|
|
}
|