public void setRedstonePower(SignActionEvent info, boolean newPowerState) { // Change in redstone power? if (!LogicUtil.addOrRemove(poweredBlocks, info.getBlock(), newPowerState)) { return; } // Execute event SignAction.executeAll( info, info.isPowerInverted() != newPowerState ? SignActionType.REDSTONE_ON : SignActionType.REDSTONE_OFF); }
@EventHandler(priority = EventPriority.MONITOR) public void onChunkLoad(ChunkLoadEvent event) { // Set the initial power state of all signs within this Chunk SignActionEvent info; try { for (BlockState state : WorldUtil.getBlockStates(event.getChunk())) { if (state instanceof Sign) { info = new SignActionEvent(state.getBlock()); LogicUtil.addOrRemove(poweredBlocks, info.getBlock(), isPowered(info)); } } } catch (Throwable t) { TrainCarts.plugin .getLogger() .log( Level.SEVERE, "Error while initializing sign power states in chunk " + event.getChunk().getX() + "/" + event.getChunk().getZ(), t); } }