From cbc1aeacbeaa2cf4c3f716026e8a672ea6806827 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sun, 30 Dec 2012 04:32:20 +0000 Subject: [PATCH] Implement event toggle. --- .../earth2me/essentials/signs/EssentialsSign.java | 6 ++++++ .../earth2me/essentials/signs/SignBlockListener.java | 12 ++++++------ .../essentials/signs/SignEntityListener.java | 4 ++-- .../essentials/signs/SignPlayerListener.java | 2 +- .../earth2me/essentials/signs/SignProtection.java | 6 ++++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index e5f125cf8..aeecf5368 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack; public class EssentialsSign { private static final Set EMPTY_SET = new HashSet(); + protected transient final String signName; public EssentialsSign(final String signName) @@ -258,6 +259,11 @@ public class EssentialsSign { return EMPTY_SET; } + + public boolean areHeavyEventRequired() + { + return false; + } protected final void validateTrade(final ISign sign, final int index, final IEssentials ess) throws SignException { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 517c313cc..a48ca3924 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -65,7 +65,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.onBlockBreak(block, player, ess)) { LOGGER.log(Level.INFO, "A block was protected by a sign."); @@ -148,7 +148,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); @@ -176,7 +176,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); @@ -204,7 +204,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); @@ -233,7 +233,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); @@ -264,7 +264,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); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index edc5b856d..bb188f94f 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -39,7 +39,7 @@ public class SignEntityListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType())) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType())) { event.setCancelled(!sign.onBlockExplode(block, ess)); return; @@ -67,7 +67,7 @@ public class SignEntityListener implements Listener } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockBreak(block, ess)) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index 12296b023..35fa03f3f 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -77,7 +77,7 @@ public class SignPlayerListener implements Listener { for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (sign.getBlocks().contains(block.getType()) + if (sign.areHeavyEventRequired() && sign.getBlocks().contains(block.getType()) && !sign.onBlockInteract(block, event.getPlayer(), ess)) { event.setCancelled(true); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 1ea26c859..b5a679324 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -241,6 +241,12 @@ public class SignProtection extends EssentialsSign { return protectedBlocks; } + + @Override + public boolean areHeavyEventRequired() + { + return true; + } @Override protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException