Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
BlockPistonEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.Material;
4 import org.bukkit.block.Block;
7 
8 /**
9  * Called when a piston block is triggered
10  */
11 public abstract class BlockPistonEvent extends BlockEvent implements Cancellable {
12  private boolean cancelled;
13  private final BlockFace direction;
14 
15  public BlockPistonEvent(final Block block, final BlockFace direction) {
16  super(block);
17  this.direction = direction;
18  }
19 
20  public boolean isCancelled() {
21  return this.cancelled;
22  }
23 
24  public void setCancelled(boolean cancelled) {
25  this.cancelled = cancelled;
26  }
27 
28  /**
29  * Returns true if the Piston in the event is sticky.
30  *
31  * @return stickiness of the piston
32  */
33  public boolean isSticky() {
34  return block.getType() == Material.PISTON_STICKY_BASE;
35  }
36 
37  /**
38  * Return the direction in which the piston will operate.
39  *
40  * @return direction of the piston
41  */
43  // Both are meh!
44  // return ((PistonBaseMaterial) block.getType().getNewData(block.getData())).getFacing();
45  // return ((PistonBaseMaterial) block.getState().getData()).getFacing();
46  return direction;
47  }
48 }