summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-07-18 01:39:41 +0200
committersnowleo <schneeleo@gmail.com>2011-07-18 01:39:41 +0200
commit1556801834ffc893788e77a49f26a4f217a8c453 (patch)
treea24822bdaeff09d342f1d0ea61fdd76e00114a8d
parente0dc003464cbfdb99bacc061b5e92a781eccf88a (diff)
downloadEssentials-1556801834ffc893788e77a49f26a4f217a8c453.tar
Essentials-1556801834ffc893788e77a49f26a4f217a8c453.tar.gz
Essentials-1556801834ffc893788e77a49f26a4f217a8c453.tar.lz
Essentials-1556801834ffc893788e77a49f26a4f217a8c453.tar.xz
Essentials-1556801834ffc893788e77a49f26a4f217a8c453.zip
Protect Rails and other signs from pistons
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java67
1 files changed, 66 insertions, 1 deletions
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;
+ }
+ }
+ }
}
}