SPIGOT-7308: Fix NullPointerException when calling Jukebox#setRecord()

This commit is contained in:
Parker Hawke 2023-03-22 14:21:06 -04:00
parent 388d458a61
commit f5b61387e1
No known key found for this signature in database
GPG Key ID: FD2A5649C53ADFE0

View File

@ -66,3 +66,16 @@
} }
@Override @Override
@@ -203,7 +246,11 @@
@VisibleForTesting
public void setRecordWithoutPlaying(ItemStack itemstack) {
this.items.set(0, itemstack);
- this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
+ // CraftBukkit start - add null check for level
+ if (level != null) {
+ this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
+ }
+ // CraftBukkit end
this.setChanged();
}
}