001    package org.bukkit.event.player;
002    
003    import org.bukkit.entity.Item;
004    import org.bukkit.entity.Player;
005    import org.bukkit.event.Cancellable;
006    import org.bukkit.event.HandlerList;
007    
008    /**
009     * Thrown when a player picks an item up from the ground
010     */
011    public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable {
012        private static final HandlerList handlers = new HandlerList();
013        private final Item item;
014        private boolean cancel = false;
015        private final int remaining;
016    
017        public PlayerPickupItemEvent(final Player player, final Item item, final int remaining) {
018            super(player);
019            this.item = item;
020            this.remaining = remaining;
021        }
022    
023        /**
024         * Gets the Item picked up by the player.
025         *
026         * @return Item
027         */
028        public Item getItem() {
029            return item;
030        }
031    
032        /**
033         * Gets the amount remaining on the ground, if any
034         *
035         * @return amount remaining on the ground
036         */
037        public int getRemaining() {
038            return remaining;
039        }
040    
041        public boolean isCancelled() {
042            return cancel;
043        }
044    
045        public void setCancelled(boolean cancel) {
046            this.cancel = cancel;
047        }
048    
049        @Override
050        public HandlerList getHandlers() {
051            return handlers;
052        }
053    
054        public static HandlerList getHandlerList() {
055            return handlers;
056        }
057    }