private void finishPistonMove(BlockPistonEvent causeEvent, Collection<BlockTransformEvent> wrapperEvents) { // If ANY of the pushed block events are cancelled, the piston jams and the entire causing event is cancelled. for(BlockTransformEvent bte : wrapperEvents) { if(bte.isCancelled()) { causeEvent.setCancelled(true); break; } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onTransform(BlockTransformEvent event) { if(event.getCause() instanceof BlockPistonEvent) return; Block block = event.getOldState().getBlock(); TrackerInfo info = blocks.get(block); if(info != null && !isPlaced(event.getNewState())) { clearBlock(block); } }
@EventHandler public void onPiston(BlockPistonEvent event) { if(GarbageControl.DespawningIce.contains(event.getBlock().getRelative(event.getDirection()).getLocation())) { event.setCancelled(true); } }