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