|
1 | 1 | package com.earth2me.essentials; |
2 | 2 |
|
| 3 | +import com.earth2me.essentials.signs.EssentialsSign; |
3 | 4 | import com.earth2me.essentials.utils.LocationUtil; |
4 | 5 | import java.util.Locale; |
5 | 6 | import net.ess3.api.IEssentials; |
6 | 7 | import org.bukkit.GameMode; |
7 | 8 | import org.bukkit.Material; |
8 | | -import org.bukkit.block.BlockState; |
9 | | -import org.bukkit.block.CreatureSpawner; |
| 9 | +import org.bukkit.block.*; |
10 | 10 | import org.bukkit.entity.EntityType; |
11 | 11 | import org.bukkit.event.EventHandler; |
12 | 12 | import org.bukkit.event.EventPriority; |
13 | 13 | import org.bukkit.event.Listener; |
| 14 | +import org.bukkit.event.block.BlockPistonRetractEvent; |
14 | 15 | import org.bukkit.event.block.BlockPlaceEvent; |
15 | 16 | import org.bukkit.inventory.ItemStack; |
16 | 17 |
|
@@ -68,4 +69,26 @@ public void run() |
68 | 69 | }); |
69 | 70 | } |
70 | 71 | } |
| 72 | + |
| 73 | + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) |
| 74 | + public void onBlockPistonRetract(BlockPistonRetractEvent event) |
| 75 | + { |
| 76 | + final Block block = event.getRetractLocation().getBlock(); |
| 77 | + for (BlockFace face : new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.UP }) |
| 78 | + { |
| 79 | + final Block search = block.getRelative(face, 1); |
| 80 | + final Material type = search.getType(); |
| 81 | + if (type == Material.SIGN || type == Material.SIGN_POST) |
| 82 | + { |
| 83 | + final Sign sign = (Sign)(search.getState()); |
| 84 | + for (final EssentialsSign esign : ess.getSettings().enabledSigns()) |
| 85 | + { |
| 86 | + if (sign.getLine(0).equalsIgnoreCase(esign.getSuccessName())) |
| 87 | + { |
| 88 | + event.setCancelled(true); |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
71 | 94 | } |
0 commit comments