summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Broes <erikbroes@grum.nl>2012-01-17 18:58:29 +0100
committerErik Broes <erikbroes@grum.nl>2012-01-17 19:51:11 +0100
commit8874b94185eda3b4e9e69c354d9c7ec0889cb8e2 (patch)
tree230d5d2ad4132bf20633dace6c743270601b0976 /src
parentc2e82a68c1e4454a04d59dd2af75b040c1509d29 (diff)
downloadbukkit-8874b94185eda3b4e9e69c354d9c7ec0889cb8e2.tar
bukkit-8874b94185eda3b4e9e69c354d9c7ec0889cb8e2.tar.gz
bukkit-8874b94185eda3b4e9e69c354d9c7ec0889cb8e2.tar.lz
bukkit-8874b94185eda3b4e9e69c354d9c7ec0889cb8e2.tar.xz
bukkit-8874b94185eda3b4e9e69c354d9c7ec0889cb8e2.zip
[Bleeding] Added EntityShootBowEvent. Thanks Zeerix.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/event/Event.java6
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityListener.java7
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java81
3 files changed, 94 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index 7dc9e82e..70a80073 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -793,6 +793,12 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.entity.EntityCreatePortalEvent
*/
ENTITY_CREATE_PORTAL(Category.LIVING_ENTITY, EntityCreatePortalEvent.class),
+ /**
+ * Called when a LivingEntity shoots a bow firing an arrow
+ *
+ * @see org.bukkit.event.entity.EntityShootBowEvent
+ */
+ ENTITY_SHOOT_BOW(Category.LIVING_ENTITY, EntityShootBowEvent.class),
/**
* WEATHER EVENTS
diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java
index 3fda2181..234ff22d 100644
--- a/src/main/java/org/bukkit/event/entity/EntityListener.java
+++ b/src/main/java/org/bukkit/event/entity/EntityListener.java
@@ -158,6 +158,13 @@ public class EntityListener implements Listener {
public void onFoodLevelChange(FoodLevelChangeEvent event) {}
/**
+ * Called when a LivingEntity shoots a bow firing an arrow
+ *
+ * @param event Relevant event details
+ */
+ public void onEntityShootBow(EntityShootBowEvent event) {}
+
+ /**
* Called when a Slime splits into smaller Slimes upon death
*
* @param event Relevant event details
diff --git a/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java b/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java
new file mode 100644
index 00000000..8eca2edc
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java
@@ -0,0 +1,81 @@
+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;
+ }
+}