diff options
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 517c313cc..fce49958e 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -32,6 +32,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -43,6 +44,13 @@ public class SignBlockListener implements Listener public boolean protectSignsAndBlocks(final Block block, final Player player) { + // prevent any signs be broken by destroying the block they are attached to + if (EssentialsSign.checkIfBlockBreaksSigns(block)) + { + LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign."); + return true; + } + final int mat = block.getTypeId(); if (mat == SIGN_POST || mat == WALL_SIGN) { @@ -57,15 +65,10 @@ public class SignBlockListener implements Listener } } } - // prevent any signs be broken by destroying the block they are attached to - if (EssentialsSign.checkIfBlockBreaksSigns(block)) - { - LOGGER.log(Level.INFO, "Prevented that a block was broken next to a sign."); - return true; - } + for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, player, ess)) { LOGGER.log(Level.INFO, "A block was protected by a sign."); @@ -80,6 +83,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } User user = ess.getUser(event.getPlayer()); @@ -105,6 +109,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -129,6 +134,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -148,7 +154,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPlace(block, event.getPlayer(), ess)) { event.setCancelled(true); @@ -162,6 +168,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -176,7 +183,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBurn(block, ess)) { event.setCancelled(true); @@ -190,6 +197,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -204,7 +212,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockIgnite(block, ess)) { event.setCancelled(true); @@ -218,6 +226,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -233,7 +242,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { event.setCancelled(true); @@ -248,6 +257,7 @@ public class SignBlockListener implements Listener { if (ess.getSettings().areSignsDisabled()) { + event.getHandlers().unregister(this); return; } @@ -264,7 +274,7 @@ public class SignBlockListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockPush(block, ess)) { event.setCancelled(true); |