fix pistons removing shulker shops

This commit is contained in:
DaniFoldi 2021-08-03 21:23:00 +03:00
parent 9a1eda96b2
commit 7f33895986

View File

@ -12,6 +12,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; 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.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent; 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) @EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent e) { public void onBlockPlace(BlockPlaceEvent e) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();