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