Skip to content

Instantly share code, notes, and snippets.

@rmsy
Last active December 14, 2015 23:39
Show Gist options
  • Save rmsy/5166848 to your computer and use it in GitHub Desktop.
Save rmsy/5166848 to your computer and use it in GitHub Desktop.
/**
* Called on a piston extend event.
*
* @param e The piston extend event.
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPistonExtend(@Nonnull final BlockPistonExtendEvent e) {
boolean allowed = false;
if (hasPermission(e.getBlock().getRelative(e.getDirection()).getLocation(), WorldEvent.PISTON_EXTENSION)) {
allowed = true;
for (Block block : e.getBlocks()) {
if (!hasPermission(block.getLocation(), WorldEvent.PISTON_EXTENSION)) {
allowed = false;
break;
}
}
}
if (!allowed) {
e.setCancelled(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment