From a427c8c5a0a6c2ddbc5426fdb557b9d755618edd Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 6 May 2020 20:53:59 +0100 Subject: [PATCH] Fix shop removal with partial transactions (Fixes #307) --- .../PostTransaction/EmptyShopDeleter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java index 4a2fe0c..e831849 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PostTransaction/EmptyShopDeleter.java @@ -52,7 +52,19 @@ public class EmptyShopDeleter implements Listener { } private static boolean shopShouldBeRemoved(Inventory inventory, ItemStack[] stock) { - return Properties.REMOVE_EMPTY_SHOPS && !ChestShopSign.isAdminShop(inventory) && !InventoryUtil.hasItems(stock, inventory); + if (Properties.REMOVE_EMPTY_SHOPS && !ChestShopSign.isAdminShop(inventory)) { + if (Properties.ALLOW_PARTIAL_TRANSACTIONS) { + for (ItemStack itemStack : stock) { + if (inventory.containsAtLeast(itemStack, 1)) { + return false; + } + } + return true; + } else if (!InventoryUtil.hasItems(stock, inventory)) { + return true; + } + } + return false; } private static boolean isInRemoveWorld(Sign sign) {