Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
InventoryInteractEvent.java
1 package org.bukkit.event.inventory;
2 
8 
9 /**
10  * An abstract base class for events that describe an interaction between a
11  * HumanEntity and the contents of an Inventory.
12  */
13 public abstract class InventoryInteractEvent extends InventoryEvent implements Cancellable {
14  private Result result = Result.DEFAULT;
15 
16  public InventoryInteractEvent(InventoryView transaction) {
17  super(transaction);
18  }
19 
20  /**
21  * Gets the player who performed the click.
22  *
23  * @return The clicking player.
24  */
26  return getView().getPlayer();
27  }
28 
29  /**
30  * Sets the result of this event. This will change whether or not this
31  * event is considered cancelled.
32  *
33  * @see #isCancelled()
34  * @param newResult the new {@link Result} for this event
35  */
36  public void setResult(Result newResult) {
37  result = newResult;
38  }
39 
40  /**
41  * Gets the {@link Result} of this event. The Result describes the
42  * behavior that will be applied to the inventory in relation to this
43  * event.
44  *
45  * @return the Result of this event.
46  */
47  public Result getResult() {
48  return result;
49  }
50 
51  /**
52  * Gets whether or not this event is cancelled. This is based off of the
53  * Result value returned by {@link #getResult()}. Result.ALLOW and
54  * Result.DEFAULT will result in a returned value of false, but
55  * Result.DENY will result in a returned value of true.
56  * <p>
57  * {@inheritDoc}
58  *
59  * @return whether the event is cancelled
60  */
61  public boolean isCancelled() {
62  return getResult() == Result.DENY;
63  }
64 
65  /**
66  * Proxy method to {@link #setResult(Event.Result)} for the Cancellable
67  * interface. {@link #setResult(Event.Result)} is preferred, as it allows
68  * you to specify the Result beyond Result.DENY and Result.ALLOW.
69  * <p>
70  * {@inheritDoc}
71  *
72  * @param toCancel result becomes DENY if true, ALLOW if false
73  */
74  public void setCancelled(boolean toCancel) {
75  setResult(toCancel ? Result.DENY : Result.ALLOW);
76  }
77 
78 }
abstract HumanEntity getPlayer()