Implement event toggle.

This commit is contained in:
KHobbits 2012-12-30 04:32:20 +00:00
parent a1b2773bf5
commit cbc1aeacbe
5 changed files with 21 additions and 9 deletions

View File

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsSign
{
private static final Set<Material> EMPTY_SET = new HashSet<Material>();
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
{

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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