Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockDispenseEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
7 import org.bukkit.util.Vector;
8 
9 /**
10  * Called when an item is dispensed from a block.
11  * <p>
12  * If a Block Dispense event is cancelled, the block will not dispense the
13  * item.
14  */
15 public class BlockDispenseEvent extends BlockEvent implements Cancellable {
16  private static final HandlerList handlers = new HandlerList();
17  private boolean cancelled = false;
18  private ItemStack item;
19  private Vector velocity;
20 
21  public BlockDispenseEvent(final Block block, final ItemStack dispensed, final Vector velocity) {
22  super(block);
23  this.item = dispensed;
24  this.velocity = velocity;
25  }
26 
27  /**
28  * Gets the item that is being dispensed. Modifying the returned item will
29  * have no effect, you must use {@link
30  * #setItem(org.bukkit.inventory.ItemStack)} instead.
31  *
32  * @return An ItemStack for the item being dispensed
33  */
34  public ItemStack getItem() {
35  return item.clone();
36  }
37 
38  /**
39  * Sets the item being dispensed.
40  *
41  * @param item the item being dispensed
42  */
43  public void setItem(ItemStack item) {
44  this.item = item;
45  }
46 
47  /**
48  * Gets the velocity.
49  * <p>
50  * Note: Modifying the returned Vector will not change the velocity, you
51  * must use {@link #setVelocity(org.bukkit.util.Vector)} instead.
52  *
53  * @return A Vector for the dispensed item's velocity
54  */
55  public Vector getVelocity() {
56  return velocity.clone();
57  }
58 
59  /**
60  * Sets the velocity of the item being dispensed.
61  *
62  * @param vel the velocity of the item being dispensed
63  */
64  public void setVelocity(Vector vel) {
65  velocity = vel;
66  }
67 
68  public boolean isCancelled() {
69  return cancelled;
70  }
71 
72  public void setCancelled(boolean cancel) {
73  cancelled = cancel;
74  }
75 
76  @Override
77  public HandlerList getHandlers() {
78  return handlers;
79  }
80 
81  public static HandlerList getHandlerList() {
82  return handlers;
83  }
84 }