summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Ward <chris@chrisgward.com>2014-03-26 22:00:57 +1100
committerChris Ward <chris@chrisgward.com>2014-03-26 22:00:57 +1100
commitb673882b2f1583d8e885789b2cc6ed82f7bd4c06 (patch)
tree85d9d37ae8ae59d6ab3376997b1fbb2047b9900c
parent200dbda6d3a09c1b9df8a3d4b699ab4962f258dc (diff)
downloadEssentials-b673882b2f1583d8e885789b2cc6ed82f7bd4c06.tar
Essentials-b673882b2f1583d8e885789b2cc6ed82f7bd4c06.tar.gz
Essentials-b673882b2f1583d8e885789b2cc6ed82f7bd4c06.tar.lz
Essentials-b673882b2f1583d8e885789b2cc6ed82f7bd4c06.tar.xz
Essentials-b673882b2f1583d8e885789b2cc6ed82f7bd4c06.zip
Do not allow a block with an Essentials Sign attached to it to be pulled with a sticky piston
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
index 225965c2b..55b05a0e1 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
@@ -1,16 +1,17 @@
package com.earth2me.essentials;
+import com.earth2me.essentials.signs.EssentialsSign;
import com.earth2me.essentials.utils.LocationUtil;
import java.util.Locale;
import net.ess3.api.IEssentials;
import org.bukkit.GameMode;
import org.bukkit.Material;
-import org.bukkit.block.BlockState;
-import org.bukkit.block.CreatureSpawner;
+import org.bukkit.block.*;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
@@ -68,4 +69,26 @@ public class EssentialsBlockListener implements Listener
});
}
}
+
+ @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
+ public void onBlockPistonRetract(BlockPistonRetractEvent event)
+ {
+ final Block block = event.getRetractLocation().getBlock();
+ for (BlockFace face : new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.UP })
+ {
+ final Block search = block.getRelative(face, 1);
+ final Material type = search.getType();
+ if (type == Material.SIGN || type == Material.SIGN_POST)
+ {
+ final Sign sign = (Sign)(search.getState());
+ for (final EssentialsSign esign : ess.getSettings().enabledSigns())
+ {
+ if (sign.getLine(0).equalsIgnoreCase(esign.getSuccessName()))
+ {
+ event.setCancelled(true);
+ }
+ }
+ }
+ }
+ }
}