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