001    
002    package org.bukkit.event.inventory;
003    
004    import org.bukkit.inventory.InventoryView;
005    import org.bukkit.entity.HumanEntity;
006    import org.bukkit.event.Cancellable;
007    import org.bukkit.event.HandlerList;
008    
009    /**
010     * Represents a player related inventory event
011     */
012    public class InventoryOpenEvent extends InventoryEvent implements Cancellable {
013        private static final HandlerList handlers = new HandlerList();
014        private boolean cancelled;
015    
016        public InventoryOpenEvent(InventoryView transaction) {
017            super(transaction);
018            this.cancelled = false;
019        }
020    
021        /**
022         * Returns the player involved in this event
023         * @return Player who is involved in this event
024         */
025        public final HumanEntity getPlayer() {
026            return transaction.getPlayer();
027        }
028    
029        /**
030         * Gets the cancellation state of this event. A cancelled event will not
031         * be executed in the server, but will still pass to other plugins
032         *
033         * If an inventory open event is cancelled, the inventory screen will not show.
034         *
035         * @return true if this event is cancelled
036         */
037        public boolean isCancelled() {
038            return cancelled;
039        }
040    
041        /**
042         * Sets the cancellation state of this event. A cancelled event will not
043         * be executed in the server, but will still pass to other plugins
044         *
045         * If an inventory open event is cancelled, the inventory screen will not show.
046         *
047         * @param cancel true if you wish to cancel this event
048         */
049        public void setCancelled(boolean cancel) {
050            cancelled = cancel;
051        }
052    
053        @Override
054        public HandlerList getHandlers() {
055            return handlers;
056        }
057    
058        public static HandlerList getHandlerList() {
059            return handlers;
060        }
061    }