diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java b/src/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java index fa7a6cda..2ca133b1 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardBlockListener.java @@ -39,6 +39,7 @@ import static com.sk89q.worldguard.bukkit.BukkitUtil.*; public class WorldGuardBlockListener extends BlockListener { + /** * Plugin. */ @@ -105,6 +106,22 @@ public void onBlockDamage(BlockDamageEvent event) { return; } } + + Block blockDamaged = event.getBlock(); + if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) { + + + Vector pt = toVector(blockDamaged); + LocalPlayer localPlayer = plugin.wrapPlayer(player); + + if (!plugin.hasPermission(player, "/regionbypass") + && !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { + player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); + + event.setCancelled(true); + return; + } + } } /** @@ -473,7 +490,10 @@ public void onBlockRightClick(BlockRightClickEvent event) { && !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); - blockClicked.setData((byte) (blockClicked.getData() - 1)); + byte newData = (byte) (blockClicked.getData() - 1); + newData = newData < 0 ? 0 : newData; + + blockClicked.setData(newData); player.setHealth(player.getHealth() - 3); return;