diff --git a/src/main/java/com/alttd/playershops/shop/PlayerShop.java b/src/main/java/com/alttd/playershops/shop/PlayerShop.java index 1f5c3f8..51c935e 100644 --- a/src/main/java/com/alttd/playershops/shop/PlayerShop.java +++ b/src/main/java/com/alttd/playershops/shop/PlayerShop.java @@ -148,9 +148,10 @@ public class PlayerShop { } public Inventory getInventory() { - // Could use a check if the block is still an InventoryHolder. - InventoryHolder container = (InventoryHolder) shopLocation.getBlock().getState(); - return container.getInventory(); + if (shopLocation.getBlock().getState() instanceof InventoryHolder inventoryHolder) { + return inventoryHolder.getInventory(); + } + return null; } public boolean isInitialized() {