From 4bd443c69fb15184dcce095180e303476374ab62 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Mon, 2 Nov 2020 01:08:15 +0100 Subject: [PATCH] Fix NPE in StockCounter for admin shops/missing containers --- .../ChestShop/Listeners/Modules/StockCounterModule.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/StockCounterModule.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/StockCounterModule.java index 3961f75..9bb86ca 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/StockCounterModule.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/StockCounterModule.java @@ -10,6 +10,7 @@ import com.Acrobot.ChestShop.Events.TransactionEvent; import com.Acrobot.ChestShop.Signs.ChestShopSign; import com.Acrobot.ChestShop.Utils.uBlock; import org.bukkit.Bukkit; +import org.bukkit.block.Container; import org.bukkit.block.Sign; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -55,9 +56,10 @@ public class StockCounterModule implements Listener { ItemStack itemTradedByShop = determineItemTradedByShop(event.getSignLine(ITEM_LINE)); if (itemTradedByShop != null) { - Inventory chestShopInventory = uBlock.findConnectedContainer(event.getSign()).getInventory(); - - event.setSignLine(QUANTITY_LINE, getQuantityLineWithCounter(quantity, itemTradedByShop, chestShopInventory)); + Container container = uBlock.findConnectedContainer(event.getSign()); + if (container != null) { + event.setSignLine(QUANTITY_LINE, getQuantityLineWithCounter(quantity, itemTradedByShop, container.getInventory())); + } } }