mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-25 18:48:24 +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)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -212,8 +213,8 @@ public class EssentialsSign
|
|||||||
final Block signblock = block.getRelative(blockFace);
|
final Block signblock = block.getRelative(blockFace);
|
||||||
if (signblock.getType() == Material.WALL_SIGN)
|
if (signblock.getType() == Material.WALL_SIGN)
|
||||||
{
|
{
|
||||||
final org.bukkit.material.Sign sign = (org.bukkit.material.Sign)signblock.getState().getData();
|
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
|
||||||
if (sign.getFacing() == blockFace)
|
if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -222,6 +223,11 @@ public class EssentialsSign
|
|||||||
return false;
|
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
|
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -122,8 +122,9 @@ public class SignBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block against = event.getBlockAgainst();
|
final Block against = event.getBlockAgainst();
|
||||||
if (against.getType() == Material.WALL_SIGN
|
if ((against.getType() == Material.WALL_SIGN
|
||||||
|| against.getType() == Material.SIGN_POST)
|
|| against.getType() == Material.SIGN_POST)
|
||||||
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against)))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -155,9 +156,10 @@ public class SignBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if ((block.getType() == Material.WALL_SIGN
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getType() == Material.SIGN_POST
|
|| block.getType() == Material.SIGN_POST)
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -189,13 +191,14 @@ public class SignBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
public void onBlockPistonExtend(final BlockPistonExtendEvent event)
|
||||||
{
|
{
|
||||||
for (Block block : event.getBlocks())
|
for (Block block : event.getBlocks())
|
||||||
{
|
{
|
||||||
if ((block.getType() == Material.WALL_SIGN
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getType() == Material.SIGN_POST
|
|| block.getType() == Material.SIGN_POST)
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -214,14 +217,15 @@ public class SignBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
public void onBlockPistonRetract(final BlockPistonRetractEvent event)
|
||||||
{
|
{
|
||||||
if (event.isSticky())
|
if (event.isSticky())
|
||||||
{
|
{
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if ((block.getType() == Material.WALL_SIGN
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getType() == Material.SIGN_POST
|
|| block.getType() == Material.SIGN_POST)
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -11,20 +11,20 @@ public class SignEntityListener extends EntityListener
|
|||||||
{
|
{
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
|
|
||||||
public SignEntityListener(IEssentials ess)
|
public SignEntityListener(final IEssentials ess)
|
||||||
{
|
{
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityExplode(EntityExplodeEvent event)
|
public void onEntityExplode(final EntityExplodeEvent event)
|
||||||
{
|
{
|
||||||
for (Block block : event.blockList())
|
for (Block block : event.blockList())
|
||||||
{
|
{
|
||||||
if ((block.getType() == Material.WALL_SIGN
|
if (((block.getType() == Material.WALL_SIGN
|
||||||
|| block.getType() == Material.SIGN_POST
|
|| block.getType() == Material.SIGN_POST)
|
||||||
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
|
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|
||||||
|
|| EssentialsSign.checkIfBlockBreaksSigns(block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user