summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-08-08 15:07:26 +0200
committersnowleo <schneeleo@gmail.com>2011-08-08 15:07:26 +0200
commitcf4752dad6a5e217f916a1906c732226054fdcad (patch)
treec2d0c26681a4e97d92d52a2c85ed39098023d7d5
parenta085503c84698544b83820b03b32e6f7c1334ff2 (diff)
downloadEssentials-cf4752dad6a5e217f916a1906c732226054fdcad.tar
Essentials-cf4752dad6a5e217f916a1906c732226054fdcad.tar.gz
Essentials-cf4752dad6a5e217f916a1906c732226054fdcad.tar.lz
Essentials-cf4752dad6a5e217f916a1906c732226054fdcad.tar.xz
Essentials-cf4752dad6a5e217f916a1906c732226054fdcad.zip
Restrict sign protections to valid signs only
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java30
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java12
3 files changed, 32 insertions, 22 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
index 52b16404e..ec2bd7125 100644
--- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
+++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java
@@ -196,7 +196,8 @@ public class EssentialsSign
public static boolean checkIfBlockBreaksSigns(final Block block)
{
- if (block.getRelative(BlockFace.UP).getType() == Material.SIGN_POST)
+ final Block sign = block.getRelative(BlockFace.UP);
+ if (sign.getType() == Material.SIGN_POST && isValidSign(new BlockSign(sign)))
{
return true;
}
@@ -212,8 +213,8 @@ public class EssentialsSign
final Block signblock = block.getRelative(blockFace);
if (signblock.getType() == Material.WALL_SIGN)
{
- final org.bukkit.material.Sign sign = (org.bukkit.material.Sign)signblock.getState().getData();
- if (sign.getFacing() == blockFace)
+ final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
+ if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
{
return true;
}
@@ -222,6 +223,11 @@ public class EssentialsSign
return false;
}
+ public static boolean isValidSign(final ISign sign)
+ {
+ return sign.getLine(0).matches("ยง1\\[.*\\]");
+ }
+
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{
return true;
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java
index e772a5108..6f07b67b2 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java
@@ -122,8 +122,9 @@ public class SignBlockListener extends BlockListener
}
final Block against = event.getBlockAgainst();
- if (against.getType() == Material.WALL_SIGN
- || against.getType() == Material.SIGN_POST)
+ if ((against.getType() == Material.WALL_SIGN
+ || against.getType() == Material.SIGN_POST)
+ && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against)))
{
event.setCancelled(true);
return;
@@ -155,9 +156,10 @@ public class SignBlockListener extends BlockListener
}
final Block block = event.getBlock();
- if ((block.getType() == Material.WALL_SIGN
- || block.getType() == Material.SIGN_POST
- || EssentialsSign.checkIfBlockBreaksSigns(block)))
+ if (((block.getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST)
+ && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
+ || EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
@@ -189,13 +191,14 @@ public class SignBlockListener extends BlockListener
}
@Override
- public void onBlockPistonExtend(BlockPistonExtendEvent event)
+ public void onBlockPistonExtend(final BlockPistonExtendEvent event)
{
for (Block block : event.getBlocks())
{
- if ((block.getType() == Material.WALL_SIGN
- || block.getType() == Material.SIGN_POST
- || EssentialsSign.checkIfBlockBreaksSigns(block)))
+ if (((block.getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST)
+ && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
+ || EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
@@ -214,14 +217,15 @@ public class SignBlockListener extends BlockListener
}
@Override
- public void onBlockPistonRetract(BlockPistonRetractEvent event)
+ public void onBlockPistonRetract(final BlockPistonRetractEvent event)
{
if (event.isSticky())
{
final Block block = event.getBlock();
- if ((block.getType() == Material.WALL_SIGN
- || block.getType() == Material.SIGN_POST
- || EssentialsSign.checkIfBlockBreaksSigns(block)))
+ if (((block.getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST)
+ && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
+ || EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java
index 4528c040d..3b4f28fc5 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java
@@ -11,20 +11,20 @@ public class SignEntityListener extends EntityListener
{
private final transient IEssentials ess;
- public SignEntityListener(IEssentials ess)
+ public SignEntityListener(final IEssentials ess)
{
this.ess = ess;
}
-
@Override
- public void onEntityExplode(EntityExplodeEvent event)
+ public void onEntityExplode(final EntityExplodeEvent event)
{
for (Block block : event.blockList())
{
- if ((block.getType() == Material.WALL_SIGN
- || block.getType() == Material.SIGN_POST
- || EssentialsSign.checkIfBlockBreaksSigns(block)))
+ if (((block.getType() == Material.WALL_SIGN
+ || block.getType() == Material.SIGN_POST)
+ && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
+ || EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;