From 1556801834ffc893788e77a49f26a4f217a8c453 Mon Sep 17 00:00:00 2001 From: snowleo Date: Mon, 18 Jul 2011 01:39:41 +0200 Subject: Protect Rails and other signs from pistons --- .../protect/EssentialsProtectBlockListener.java | 67 +++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'EssentialsProtect') diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index de6791305..7b5f93d0e 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -336,6 +336,38 @@ public class EssentialsProtectBlockListener extends BlockListener event.setCancelled(true); return; } + if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS + || block.getType() == Material.RAILS) + && prot.getSettingBool(ProtectConfig.protect_rails)) + { + event.setCancelled(true); + return; + } + if (prot.getSettingBool(ProtectConfig.protect_signs)) + { + for (BlockFace blockFace : faces) + { + if (blockFace == BlockFace.DOWN) + { + continue; + } + final Block sign = block.getRelative(blockFace); + if ((blockFace == BlockFace.UP || blockFace == BlockFace.SELF) + && sign.getType() == Material.SIGN_POST) + { + event.setCancelled(true); + return; + } + if ((blockFace == BlockFace.NORTH || blockFace == BlockFace.EAST + || blockFace == BlockFace.SOUTH || blockFace == BlockFace.WEST + || blockFace == BlockFace.SELF) + && sign.getType() == Material.WALL_SIGN) + { + event.setCancelled(true); + return; + } + } + } } } @@ -346,10 +378,43 @@ public class EssentialsProtectBlockListener extends BlockListener { return; } - if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, event.getRetractLocation().getBlock().getTypeId())) + final Block block = event.getRetractLocation().getBlock(); + if (prot.checkProtectionItems(ProtectConfig.blacklist_piston, block.getTypeId())) { event.setCancelled(true); return; } + if ((block.getRelative(BlockFace.UP).getType() == Material.RAILS + || block.getType() == Material.RAILS) + && prot.getSettingBool(ProtectConfig.protect_rails)) + { + event.setCancelled(true); + return; + } + if (prot.getSettingBool(ProtectConfig.protect_signs)) + { + for (BlockFace blockFace : faces) + { + if (blockFace == BlockFace.DOWN) + { + continue; + } + final Block sign = block.getRelative(blockFace); + if ((blockFace == BlockFace.UP || blockFace == BlockFace.SELF) + && sign.getType() == Material.SIGN_POST) + { + event.setCancelled(true); + return; + } + if ((blockFace == BlockFace.NORTH || blockFace == BlockFace.EAST + || blockFace == BlockFace.SOUTH || blockFace == BlockFace.WEST + || blockFace == BlockFace.SELF) + && sign.getType() == Material.WALL_SIGN) + { + event.setCancelled(true); + return; + } + } + } } } -- cgit v1.2.3