@EventHandler(ignoreCancelled = true) public void onBlockFade(BlockFadeEvent event) { Block block = event.getBlock(); if (LotteryManager.isSignRegistered(block) || !checkBlockBroken(block)) { event.setCancelled(true); return; } }
@EventHandler(ignoreCancelled = true) public void onPistonExtend(BlockPistonExtendEvent event) { for (Block block : event.getBlocks()) { if (LotteryManager.isSignRegistered(block) || !checkBlockBroken(block)) { event.setCancelled(true); return; } } }
@EventHandler(ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { for (Block block : event.blockList()) { if (LotteryManager.isSignRegistered(block) || !checkBlockBroken(block)) { event.setCancelled(true); return; } } }
@EventHandler(ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); Block block = event.getBlock(); if (LotteryManager.isSignRegistered(block)) { event.setCancelled(true); ChatUtils.send(player, "lottery.error.sign.break"); return; } if (!checkBlockBroken(block)) { event.setCancelled(true); ChatUtils.send(player, "lottery.error.block.break"); return; } }
private boolean canBreakBlock(Block check, Block broken) { if (!LotteryManager.isSignRegistered(check)) return true; BlockFace attached = ((org.bukkit.material.Sign) check.getState().getData()).getAttachedFace(); Block blockAttached = check.getRelative(attached); return !LotteryPlus.locsInBounds(blockAttached.getLocation(), broken.getLocation()); }