From 37370f722c5920a279c95347987b06f13be8527e Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 2 Apr 2012 22:58:07 +0100 Subject: [PATCH] Switch sign listeners back to compare block id, rather than materials. --- .../essentials/EssentialsPlayerListener.java | 2 +- .../essentials/signs/SignBlockListener.java | 28 ++++++++++--------- .../essentials/signs/SignEntityListener.java | 8 +++--- .../essentials/signs/SignPlayerListener.java | 3 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 992c3875b..2f97490bc 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -323,7 +323,7 @@ public class EssentialsPlayerListener implements Listener { return; } - if (event.getClickedBlock().getType() == Material.BED_BLOCK && ess.getSettings().getUpdateBedAtDaytime()) + if (event.getClickedBlock().getTypeId() == Material.BED_BLOCK.getId() && ess.getSettings().getUpdateBedAtDaytime()) { event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation()); } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 72367e514..79e5bf2be 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -19,6 +19,8 @@ public class SignBlockListener implements Listener { private final transient IEssentials ess; private final static Logger LOGGER = Logger.getLogger("Minecraft"); + private final static int WALL_SIGN = Material.WALL_SIGN.getId(); + private final static int SIGN_POST = Material.SIGN_POST.getId(); public SignBlockListener(IEssentials ess) { @@ -42,7 +44,7 @@ public class SignBlockListener implements Listener public boolean protectSignsAndBlocks(final Block block, final Player player) { final int mat = block.getTypeId(); - if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) + if (mat == SIGN_POST || mat == WALL_SIGN) { final Sign csign = (Sign)block.getState(); @@ -116,16 +118,16 @@ public class SignBlockListener implements Listener } final Block against = event.getBlockAgainst(); - if ((against.getType() == Material.WALL_SIGN - || against.getType() == Material.SIGN_POST) + if ((against.getTypeId() == WALL_SIGN + || against.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against))) { event.setCancelled(true); return; } final Block block = event.getBlock(); - if (block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) { return; } @@ -150,8 +152,8 @@ public class SignBlockListener implements Listener } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -178,8 +180,8 @@ public class SignBlockListener implements Listener } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -202,8 +204,8 @@ public class SignBlockListener implements Listener { for (Block block : event.getBlocks()) { - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -228,8 +230,8 @@ public class SignBlockListener implements Listener if (event.isSticky()) { final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == WALL_SIGN + || block.getTypeId() == SIGN_POST) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index 8ca64869c..5a6ee177d 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -24,8 +24,8 @@ public class SignEntityListener implements Listener { for (Block block : event.blockList()) { - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == Material.WALL_SIGN.getId() + || block.getTypeId() == Material.SIGN_POST.getId()) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { @@ -52,8 +52,8 @@ public class SignEntityListener implements Listener } final Block block = event.getBlock(); - if (((block.getType() == Material.WALL_SIGN - || block.getType() == Material.SIGN_POST) + if (((block.getTypeId() == Material.WALL_SIGN.getId() + || block.getTypeId() == Material.SIGN_POST.getId()) && EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block))) || EssentialsSign.checkIfBlockBreaksSigns(block)) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index 75ed18500..561d8dffc 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -34,7 +34,8 @@ public class SignPlayerListener implements Listener return; } - if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) + final int mat = block.getTypeId(); + if (mat == Material.SIGN_POST.getId() || mat == Material.WALL_SIGN.getId()) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {