diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java index d2dff76..aebaf21 100644 --- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java +++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java @@ -12,6 +12,9 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockPistonEvent; +import org.bukkit.event.block.BlockPistonExtendEvent; +import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; @@ -126,6 +129,28 @@ public class ChestProtectListener implements Listener { } } + @EventHandler(ignoreCancelled = true) + public void onPistonExtend(BlockPistonExtendEvent e) { + for (Block b: e.getBlocks()) { + if (ShopUtils.isShopMaterial(b.getType())) { + if (shopUtils.isShop(b.getLocation())) { + e.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onPistonRetract(BlockPistonRetractEvent e) { + for (Block b: e.getBlocks()) { + if (ShopUtils.isShopMaterial(b.getType())) { + if (shopUtils.isShop(b.getLocation())) { + e.setCancelled(true); + } + } + } + } + @EventHandler(ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent e) { final Player p = e.getPlayer();