mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-24 18:18:29 +01:00
Restrict sign protections to valid signs only
This commit is contained in:
parent
a085503c84
commit
cf4752dad6
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user