Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockFromToEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.block.Block;
7 
8 /**
9  * Represents events with a source block and a destination block, currently
10  * only applies to liquid (lava and water) and teleporting dragon eggs.
11  * <p>
12  * If a Block From To event is cancelled, the block will not move (the liquid
13  * will not flow).
14  */
15 public class BlockFromToEvent extends BlockEvent implements Cancellable {
16  private static final HandlerList handlers = new HandlerList();
17  protected Block to;
18  protected BlockFace face;
19  protected boolean cancel;
20 
21  public BlockFromToEvent(final Block block, final BlockFace face) {
22  super(block);
23  this.face = face;
24  this.cancel = false;
25  }
26 
27  public BlockFromToEvent(final Block block, final Block toBlock) {
28  super(block);
29  this.to = toBlock;
30  this.face = BlockFace.SELF;
31  this.cancel = false;
32  }
33 
34  /**
35  * Gets the BlockFace that the block is moving to.
36  *
37  * @return The BlockFace that the block is moving to
38  */
39  public BlockFace getFace() {
40  return face;
41  }
42 
43  /**
44  * Convenience method for getting the faced Block.
45  *
46  * @return The faced Block
47  */
48  public Block getToBlock() {
49  if (to == null) {
50  to = block.getRelative(face);
51  }
52  return to;
53  }
54 
55  public boolean isCancelled() {
56  return cancel;
57  }
58 
59  public void setCancelled(boolean cancel) {
60  this.cancel = cancel;
61  }
62 
63  @Override
64  public HandlerList getHandlers() {
65  return handlers;
66  }
67 
68  public static HandlerList getHandlerList() {
69  return handlers;
70  }
71 }
Block getRelative(int modX, int modY, int modZ)