diff options
author | Feildmaster <admin@feildmaster.com> | 2011-10-16 20:47:49 -0500 |
---|---|---|
committer | Nathan Adams <dinnerbone@dinnerbone.com> | 2012-01-14 17:01:03 +0000 |
commit | c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f (patch) | |
tree | 3bedd66b9cdb7b72ff113dc80ac0713555d1aa9a /src/main/java | |
parent | 88a1512ee3d5cf0c5ea3d3d952b061ffb3f7e001 (diff) | |
download | bukkit-c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f.tar bukkit-c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f.tar.gz bukkit-c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f.tar.lz bukkit-c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f.tar.xz bukkit-c16210e2e2dd938f8ea8f0c51fe0af93e25ce00f.zip |
Added ItemDespawnEvent
Diffstat (limited to 'src/main/java')
4 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 095c19c6..681cca94 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -600,6 +600,12 @@ public abstract class Event implements Serializable { * @see org.bukkit.event.world.TreeGrowEvent */ STRUCTURE_GROW(Category.WORLD), + /** + * Called when an item despawns from a world + * + * @see org.bukkit.event.entity.ItemDespawnEvent + */ + ITEM_DESPAWN (Category.WORLD), /** * ENTITY EVENTS diff --git a/src/main/java/org/bukkit/event/entity/EntityListener.java b/src/main/java/org/bukkit/event/entity/EntityListener.java index b4399736..1e34b890 100644 --- a/src/main/java/org/bukkit/event/entity/EntityListener.java +++ b/src/main/java/org/bukkit/event/entity/EntityListener.java @@ -162,4 +162,11 @@ public class EntityListener implements Listener { * @param event Relevant event details */ public void onSlimeSplit(SlimeSplitEvent event) {} + + /** + * Called when an item despawns from a world + * + * @param event Relevant event details + */ + public void onItemDespawn(ItemDespawnEvent event) {} } diff --git a/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java new file mode 100644 index 00000000..620e247a --- /dev/null +++ b/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -0,0 +1,32 @@ +package org.bukkit.event.entity; + +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; + +public class ItemDespawnEvent extends EntityEvent implements Cancellable { + private boolean canceled; + private Location location; + + public ItemDespawnEvent(Entity spawnee, Location loc) { + super(Type.ITEM_DESPAWN, spawnee); + location = loc; + } + + public boolean isCancelled() { + return canceled; + } + + public void setCancelled(boolean cancel) { + canceled = cancel; + } + + /** + * Gets the location at which the item is despawning. + * + * @return The location at which the item is despawning + */ + 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 0bb16653..5126f9a0 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -840,6 +840,13 @@ public class JavaPluginLoader implements PluginLoader { } }; + case ITEM_DESPAWN: + return new EventExecutor() { + public void execute(Listener listener, Event event) { + ((EntityListener) listener).onItemDespawn((ItemDespawnEvent) event); + } + }; + // Vehicle Events case VEHICLE_CREATE: return new EventExecutor() { |