001    package org.bukkit.event.entity;
002    
003    import org.bukkit.Location;
004    import org.bukkit.entity.Item;
005    import org.bukkit.event.Cancellable;
006    import org.bukkit.event.HandlerList;
007    
008    /**
009     * This event is called when a {@link org.bukkit.entity.Item} is removed from
010     * the world because it has existed for 5 minutes.
011     * <p>
012     * Cancelling the event results in the item being allowed to exist for 5 more
013     * minutes. This behavior is not guaranteed and may change in future versions.
014     */
015    public class ItemDespawnEvent extends EntityEvent implements Cancellable {
016        private static final HandlerList handlers = new HandlerList();
017        private boolean canceled;
018        private final Location location;
019    
020        public ItemDespawnEvent(final Item despawnee, final Location loc) {
021            super(despawnee);
022            location = loc;
023        }
024    
025        public boolean isCancelled() {
026            return canceled;
027        }
028    
029        public void setCancelled(boolean cancel) {
030            canceled = cancel;
031        }
032    
033        @Override
034        public Item getEntity() {
035            return (Item) entity;
036        }
037    
038        /**
039         * Gets the location at which the item is despawning.
040         *
041         * @return The location at which the item is despawning
042         */
043        public Location getLocation() {
044            return location;
045        }
046    
047        @Override
048        public HandlerList getHandlers() {
049            return handlers;
050        }
051    
052        public static HandlerList getHandlerList() {
053            return handlers;
054        }
055    }