Add a check if the shop block is an inventoryholder
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user