DoubleChest left/right side holder might be null/not BlockStates. Check that.

This commit is contained in:
Phoenix616 2023-03-01 18:06:35 +01:00
parent 7d92cb820d
commit aa7bfbb7ee
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 8 additions and 2 deletions

View File

@ -46,8 +46,14 @@ public class PlayerInventory implements Listener {
List<Block> containers = new ArrayList<>();
if (holder instanceof DoubleChest) {
containers.add(((BlockState) ((DoubleChest) holder).getLeftSide()).getBlock());
containers.add(((BlockState) ((DoubleChest) holder).getRightSide()).getBlock());
InventoryHolder leftSide = ((DoubleChest) holder).getLeftSide();
if (leftSide instanceof BlockState) {
containers.add(((BlockState) leftSide).getBlock());
}
InventoryHolder rightSide = ((DoubleChest) holder).getRightSide();
if (rightSide instanceof BlockState) {
containers.add(((BlockState) rightSide).getBlock());
}
} else {
containers.add(((BlockState) holder).getBlock());
}