Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 43 lines 1.3 kB view raw
1package org.bukkit.event.block; 2 3import org.bukkit.Material; 4import org.bukkit.block.Block; 5import org.bukkit.block.BlockFace; 6import org.bukkit.event.Cancellable; 7import org.bukkit.material.PistonBaseMaterial; 8 9public abstract class BlockPistonEvent extends BlockEvent implements Cancellable { 10 private boolean cancelled; 11 12 public BlockPistonEvent(Type type, Block block) { 13 super(type, block); 14 } 15 16 public boolean isCancelled() { 17 return this.cancelled; 18 } 19 20 public void setCancelled(boolean cancelled) { 21 this.cancelled = cancelled; 22 } 23 24 /** 25 * Returns true if the Piston in the event is sticky. 26 * 27 * @return stickiness of the piston 28 */ 29 public boolean isSticky() { 30 return block.getType() == Material.PISTON_STICKY_BASE; 31 } 32 33 /** 34 * Return the direction in which the piston will operate. 35 * 36 * @return direction of the piston 37 */ 38 public BlockFace getDirection() { 39 // Both are meh! 40 // return ((PistonBaseMaterial) block.getType().getNewData(block.getData ())).getFacing(); 41 return ((PistonBaseMaterial) block.getState().getData()).getFacing(); 42 } 43}