mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-12 22:04:14 +01:00
[Fix] Essentials signs validity (#1402)
* [Fix] Essentials signs validity
Any sign in the format of &1[...] was a valid sign according to essentials, but 3rd party plugins with the same sign format would be treated equally (cancelling nearby explosions, etc)
Valid signs after this fix are:
- In the format of &1[...] as before
- Are essentials signs and enabled in the essentials config
* Revert "[Fix] Essentials signs validity"
This reverts commit 60d95b6585
.
* [Fix - v2] Essentials signs validity
Any sign in the format of &1[...] was a valid sign according to essentials, but 3rd party plugins with the same sign format would be treated equally (cancelling nearby explosions, etc)
This commit is contained in:
parent
fd63a7df4e
commit
8796dbeb56
@ -7,6 +7,7 @@ import net.ess3.api.MaxMoneyException;
|
|||||||
import net.ess3.api.events.SignBreakEvent;
|
import net.ess3.api.events.SignBreakEvent;
|
||||||
import net.ess3.api.events.SignCreateEvent;
|
import net.ess3.api.events.SignCreateEvent;
|
||||||
import net.ess3.api.events.SignInteractEvent;
|
import net.ess3.api.events.SignInteractEvent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -232,10 +233,26 @@ public class EssentialsSign {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated, use {@link #isValidSign(IEssentials, ISign)} if possible */
|
||||||
|
@Deprecated
|
||||||
public static boolean isValidSign(final ISign sign) {
|
public static boolean isValidSign(final ISign sign) {
|
||||||
return sign.getLine(0).matches("§1\\[.*\\]");
|
return sign.getLine(0).matches("§1\\[.*\\]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isValidSign(final IEssentials ess, final ISign sign) {
|
||||||
|
if (!sign.getLine(0).matches("§1\\[.*\\]"))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Validate that the sign is actually an essentials sign
|
||||||
|
String signName = ChatColor.stripColor(sign.getLine(0)).replaceAll("[^a-zA-Z]", "");
|
||||||
|
for (EssentialsSign essSign : ess.getSettings().enabledSigns()) {
|
||||||
|
if (essSign.getName().equalsIgnoreCase(signName))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public class SignBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block against = event.getBlockAgainst();
|
final Block against = event.getBlockAgainst();
|
||||||
if ((against.getType() == WALL_SIGN || against.getType() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against))) {
|
if ((against.getType() == WALL_SIGN || against.getType() == SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(against))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class SignBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ public class SignBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ public class SignBlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Block block : event.getBlocks()) {
|
for (Block block : event.getBlocks()) {
|
||||||
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ public class SignBlockListener implements Listener {
|
|||||||
final Block[] affectedBlocks = new Block[]{pistonBaseBlock, pistonBaseBlock.getRelative(event.getDirection()), event.getRetractLocation().getBlock()};
|
final Block[] affectedBlocks = new Block[]{pistonBaseBlock, pistonBaseBlock.getRelative(event.getDirection()), event.getRetractLocation().getBlock()};
|
||||||
|
|
||||||
for (Block block : affectedBlocks) {
|
for (Block block : affectedBlocks) {
|
||||||
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == WALL_SIGN || block.getType() == SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class SignEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
if (((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public class SignEntityListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
if (((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
if (((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsSign.isValidSign(ess, new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user