From a95b32ea8458ba266e05d876090ac79ba0d882d9 Mon Sep 17 00:00:00 2001 From: Ghost_chu <30802565+Ghost-chu@users.noreply.github.com> Date: Sat, 28 Dec 2019 18:01:50 +0800 Subject: [PATCH] Fix #267 Fix #267 Former-commit-id: 789e2edc8c3ce015ec1cccade6a0738648e531f0 --- .../Listeners/ShopProtectionListener.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java index 89d6b4ce5..1d896c07d 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/ShopProtectionListener.java @@ -159,9 +159,9 @@ public class ShopProtectionListener implements Listener { return; } - final HashMap shopsInChunk = plugin.getShopManager().getShops(loc.getChunk()); + final Shop shop = plugin.getShopManager().getShopIncludeAttached(loc) - if (shopsInChunk == null || shopsInChunk.isEmpty() || shopsInChunk.get(loc) == null) { + if (shop == null) { return; } @@ -172,9 +172,17 @@ public class ShopProtectionListener implements Listener { if (location == null) { return; } + + final InventoryHolder holder = event.getInitiator().getHolder(); + + if(holder instanceof Entity){ + holder.remove(); + }else if(holder instanceof Block){ + location.getBlock().breakNaturally(); + } - location.getBlock().breakNaturally(); - MsgUtil.sendGlobalAlert("[DisplayGuard] Breaked the block at " + location + " try steal the items for shop " + loc); + + MsgUtil.sendGlobalAlert("[DisplayGuard] Defened a item steal action at" + location); } //Protect Entity pickup shop