diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-01 10:45:39 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-02-01 10:45:39 +0000 |
commit | 1dba6e8874f5db0d14c14825f80279cb16f80fbd (patch) | |
tree | c93b30b9767fe6d2f09ce7bd5958215562e1a86b /src | |
parent | 3a1f5647e6ca5410d417b1136a47615e602c0cc0 (diff) | |
download | bukkit-1dba6e8874f5db0d14c14825f80279cb16f80fbd.tar bukkit-1dba6e8874f5db0d14c14825f80279cb16f80fbd.tar.gz bukkit-1dba6e8874f5db0d14c14825f80279cb16f80fbd.tar.lz bukkit-1dba6e8874f5db0d14c14825f80279cb16f80fbd.tar.xz bukkit-1dba6e8874f5db0d14c14825f80279cb16f80fbd.zip |
Added PLAYER_DROP_ITEM
Diffstat (limited to 'src')
4 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index 43807346..0db91797 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -214,6 +214,13 @@ public abstract class Event { PLAYER_ITEM_HELD (Category.PLAYER), /** + * Called when a player drops an item + * + * @see org.bukkit.event.player.PlayerDropItemEvent + */ + PLAYER_DROP_ITEM (Category.PLAYER), + + /** * BLOCK EVENTS */ diff --git a/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java new file mode 100644 index 00000000..0980c2c3 --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java @@ -0,0 +1,48 @@ + +package org.bukkit.event.player; + +import org.bukkit.entity.ItemDrop; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; + +/** + * Thrown when a player drops an item from their inventory + */ +public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { + private final ItemDrop drop; + private boolean cancel = false; + + public PlayerDropItemEvent(final Type type, final Player player, final ItemDrop drop) { + super(type, player); + this.drop = drop; + } + + /** + * Gets the ItemDrop created by the player + * + * @return ItemDrop + */ + public ItemDrop getItemDrop() { + return drop; + } + + /** + * Gets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * @return true if this event is cancelled + */ + public boolean isCancelled() { + return cancel; + } + + /** + * Sets the cancellation state of this event. A cancelled 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) { + this.cancel = cancel; + } +} diff --git a/src/main/java/org/bukkit/event/player/PlayerListener.java b/src/main/java/org/bukkit/event/player/PlayerListener.java index 3ab8d037..8905d7d1 100644 --- a/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -105,4 +105,12 @@ public class PlayerListener implements Listener { */ public void onItemHeldChange(PlayerItemHeldEvent event) { } + + /** + * Called when a player drops an item from their inventory + * + * @param event Relevant event details + */ + public void onPlayerDropItem(PlayerDropItemEvent event) { + } } diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 8dc65d3c..064739b1 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -178,6 +178,11 @@ public final class JavaPluginLoader implements PluginLoader { ((PlayerListener)listener).onItemHeldChange( (PlayerItemHeldEvent)event ); } }; + case PLAYER_DROP_ITEM: + return new EventExecutor() { public void execute( Listener listener, Event event ) { + ((PlayerListener)listener).onPlayerDropItem( (PlayerDropItemEvent)event ); + } + }; // Block Events case BLOCK_PHYSICS: |