org.bukkit.event.block.BlockPistonEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chest-server Show documentation
Show all versions of chest-server Show documentation
A spigot fork to kotlin structure and news.
The newest version!
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 final BlockFace direction;
private boolean cancelled;
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.PISTON_STICKY_BASE || block.getType() == Material.PISTON_MOVING_PIECE;
}
/**
* 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;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy