diff options
author | James Logsdon <dwarf@girsbrain.org> | 2011-02-11 17:08:53 -0500 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-02-12 01:39:44 +0100 |
commit | 164b687bcd4eef07ccf216ba0aca04309895261d (patch) | |
tree | cc973ed5bf57aae73c564cd3de3d9f1f962f0c0a /src | |
parent | 6c86db411c79e36fe78624c3506b1a784d6ba620 (diff) | |
download | bukkit-164b687bcd4eef07ccf216ba0aca04309895261d.tar bukkit-164b687bcd4eef07ccf216ba0aca04309895261d.tar.gz bukkit-164b687bcd4eef07ccf216ba0aca04309895261d.tar.lz bukkit-164b687bcd4eef07ccf216ba0aca04309895261d.tar.xz bukkit-164b687bcd4eef07ccf216ba0aca04309895261d.zip |
Adding PLAYER_PICKUP_ITEM event
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/event/Event.java | 9 | ||||
-rw-r--r-- | src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java | 55 |
2 files changed, 63 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index df84204c..50332a42 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -242,6 +242,13 @@ public abstract class Event { PLAYER_DROP_ITEM (Category.PLAYER), /** + * Called when a player picks an item up off the ground + * + * @see org.bukkit.event.player.PlayerPickupItemEvent + */ + PLAYER_PICKUP_ITEM (Category.PLAYER), + + /** * BLOCK EVENTS */ @@ -445,7 +452,7 @@ public abstract class Event { * @todo: add javadoc see comment */ ITEM_SPAWN (Category.WORLD), - + /** * Called when a world is saved * diff --git a/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java new file mode 100644 index 00000000..c71ff704 --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java @@ -0,0 +1,55 @@ + +package org.bukkit.event.player; + +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; + +/** + * Thrown when a player picks an item up from the ground + */ +public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { + private final Item item; + private boolean cancel = false; + + public PlayerPickupItemEvent(final Player player, final Item item) { + super(Event.Type.PLAYER_PICKUP_ITEM, player); + this.item = item; + } + + /** + * Gets the ItemDrop created by the player + * + * @return Item + */ + public Item getItem() { + return item; + } + + /** + * Gets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * If an item pickup event is cancelled, the item will not be picked up. + * This will not fire an event. + * + * @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 + * + * If an item pickup event is cancelled, the item will not be picked up. + * This will not fire an event. + * + * @param cancel true if you wish to cancel this event + */ + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } +} |