Skip to content

Commit b673882

Browse files
committed
Do not allow a block with an Essentials Sign attached to it to be pulled with a sticky piston
1 parent 200dbda commit b673882

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package com.earth2me.essentials;
22

3+
import com.earth2me.essentials.signs.EssentialsSign;
34
import com.earth2me.essentials.utils.LocationUtil;
45
import java.util.Locale;
56
import net.ess3.api.IEssentials;
67
import org.bukkit.GameMode;
78
import org.bukkit.Material;
8-
import org.bukkit.block.BlockState;
9-
import org.bukkit.block.CreatureSpawner;
9+
import org.bukkit.block.*;
1010
import org.bukkit.entity.EntityType;
1111
import org.bukkit.event.EventHandler;
1212
import org.bukkit.event.EventPriority;
1313
import org.bukkit.event.Listener;
14+
import org.bukkit.event.block.BlockPistonRetractEvent;
1415
import org.bukkit.event.block.BlockPlaceEvent;
1516
import org.bukkit.inventory.ItemStack;
1617

@@ -68,4 +69,26 @@ public void run()
6869
});
6970
}
7071
}
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+
}
7194
}

0 commit comments

Comments
 (0)