From 8b736da1817a06272290a6134e746da92ae6c393 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 1 Jul 2016 17:09:49 +0200 Subject: [PATCH] Prevent liquids from washing shop items away --- .../listeners/ItemProtectListener.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/de/epiceric/shopchest/listeners/ItemProtectListener.java b/src/de/epiceric/shopchest/listeners/ItemProtectListener.java index 3267d92..e50f8ab 100644 --- a/src/de/epiceric/shopchest/listeners/ItemProtectListener.java +++ b/src/de/epiceric/shopchest/listeners/ItemProtectListener.java @@ -9,13 +9,11 @@ import org.bukkit.entity.Item; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockMultiPlaceEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.*; import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.inventory.InventoryPickupItemEvent; import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerPickupItemEvent; public class ItemProtectListener implements Listener { @@ -80,4 +78,19 @@ public class ItemProtectListener implements Listener { } } + @EventHandler(priority = EventPriority.HIGH) + public void onLiquidFlow(BlockFromToEvent e) { + Block b = e.getToBlock(); + Block below = b.getRelative(BlockFace.DOWN); + + if (ShopUtils.isShop(below.getLocation())) e.setCancelled(true); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onBucketEmpty(PlayerBucketEmptyEvent e) { + Block b = e.getBlockClicked(); + + if (ShopUtils.isShop(b.getLocation())) e.setCancelled(true); + } + }