diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 7e6aed108..518e853bb 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -182,6 +182,7 @@ public class Essentials extends JavaPlugin implements IEssentials final SignEntityListener signEntityListener = new SignEntityListener(this); pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this); + pm.registerEvent(Type.ENDERMAN_PICKUP, signEntityListener, Priority.Low, this); final EssentialsEntityListener entityListener = new EssentialsEntityListener(this); pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this); diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index 17d7a5993..026fb0557 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -177,6 +177,11 @@ public class EssentialsSign } return false; } + + public boolean onBlockBreak(final Block block, final IEssentials ess) + { + return true; + } public boolean onBlockExplode(final Block block, final IEssentials ess) { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java index 3b4f28fc5..4f6736989 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignEntityListener.java @@ -3,6 +3,8 @@ package com.earth2me.essentials.signs; import com.earth2me.essentials.IEssentials; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.event.entity.EndermanPickupEvent; +import org.bukkit.event.entity.EndermanPlaceEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityListener; @@ -40,4 +42,33 @@ public class SignEntityListener extends EntityListener } } } + + @Override + public void onEndermanPickup(EndermanPickupEvent event) + { + if (event.isCancelled() || ess.getSettings().areSignsDisabled()) + { + return; + } + + 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)) + { + event.setCancelled(true); + return; + } + for (Signs signs : Signs.values()) + { + final EssentialsSign sign = signs.getSign(); + if (sign.getBlocks().contains(block.getType()) + && !sign.onBlockBreak(block, ess)) + { + event.setCancelled(true); + return; + } + } + } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 81c95f8b8..157535cd9 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -300,6 +300,14 @@ public class SignProtection extends EssentialsSign player.sendMessage(Util.format("noDestroyPermission", block.getType().toString().toLowerCase())); return false; } + + @Override + public boolean onBlockBreak(final Block block, final IEssentials ess) + { + final SignProtectionState state = isBlockProtected(block, null, null, false); + + return state == SignProtectionState.NOSIGN; + } @Override public boolean onBlockExplode(final Block block, final IEssentials ess)