summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/bukkit/event/Event.java2
-rw-r--r--src/main/java/org/bukkit/event/entity/EntityListener.java2
-rw-r--r--src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java47
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java7
4 files changed, 57 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java
index f3f91849..2c00151c 100644
--- a/src/main/java/org/bukkit/event/Event.java
+++ b/src/main/java/org/bukkit/event/Event.java
@@ -463,7 +463,7 @@ public abstract class Event implements Serializable {
/**
* Called when an ItemEntity spawns in the world
*
- * @todo: add javadoc see comment
+ * @see org.bukkit.event.entity.ItemSpawnEvent
*/
ITEM_SPAWN (Category.WORLD),
/**
diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java
index ac497639..a6ca7027 100644
--- a/src/main/java/org/bukkit/event/entity/EntityListener.java
+++ b/src/main/java/org/bukkit/event/entity/EntityListener.java
@@ -12,6 +12,8 @@ public class EntityListener implements Listener {
public void onCreatureSpawn(CreatureSpawnEvent event) {}
+ public void onItemSpawn(ItemSpawnEvent event) {}
+
public void onEntityCombust(EntityCombustEvent event) {}
public void onEntityDamage(EntityDamageEvent event) {}
diff --git a/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java b/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java
new file mode 100644
index 00000000..bff7aa17
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java
@@ -0,0 +1,47 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.Location;
+import org.bukkit.event.Cancellable;
+
+/**
+ * Called when an item is spawned into a world
+ */
+public class ItemSpawnEvent extends EntityEvent implements Cancellable {
+
+ private Location location;
+ private boolean canceled;
+
+ public ItemSpawnEvent(Entity spawnee, Location loc) {
+ super(Type.ITEM_SPAWN, spawnee);
+ this.location = loc;
+ }
+
+ /**
+ * Gets the cancellation state of this event. A canceled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @return true if this event is canceled
+ */
+ public boolean isCancelled() {
+ return canceled;
+ }
+
+ /**
+ * Sets the cancellation state of this event. A canceled event will not
+ * be executed in the server, but will still pass to other plugins
+ *
+ * @param cancel true if you wish to cancel this event
+ */
+ public void setCancelled(boolean cancel) {
+ canceled = cancel;
+ }
+
+ /**
+ * Gets the location at which the item is spawning.
+ * @return The location at which the item is spawning
+ */
+ public Location getLocation() {
+ return location;
+ }
+}
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
index 0fce8475..f757c234 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -655,6 +655,13 @@ public final class JavaPluginLoader implements PluginLoader {
}
};
+ case ITEM_SPAWN:
+ return new EventExecutor() {
+ public void execute(Listener listener, Event event) {
+ ((EntityListener) listener).onItemSpawn((ItemSpawnEvent) event);
+ }
+ };
+
case PIG_ZAP:
return new EventExecutor() {
public void execute(Listener listener, Event event) {