if (damageEvent.isCancelled()) { revert = true; } else {
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR) public void onBlockDamage(final BlockDamageEvent event) { if (!event.isCancelled() && event.getInstaBreak()) { // Keep MAYBE. if (isInstaBreak != AlmostBoolean.MAYBE) { isInstaBreak = AlmostBoolean.YES; } } else { isInstaBreak = AlmostBoolean.NO; } checkBlockDamage(event.getPlayer(), event.getBlock(), event); }
/** * Simulates the player breaking a block. This method will not break the block * if the player is in adventure or spectator mode. If the player is in survival * mode, the player will first damage the block. * * @param block The block to break. * @return {@code true} if the block was broken, {@code false} if it wasn't or * if the player was in adventure mode or in spectator mode. */ public boolean simulateBlockBreak(Block block) { if ((gamemode == GameMode.SPECTATOR || gamemode == GameMode.ADVENTURE) || (gamemode == GameMode.SURVIVAL && simulateBlockDamagePure(block).isCancelled())) return false; BlockBreakEvent event = new BlockBreakEvent(block, this); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) block.setType(Material.AIR); return !event.isCancelled(); }
return !event.isCancelled();