SPIGOT-5199: Fix NPE if setting the book of the ItemMeta of a lectern

This commit is contained in:
BlackHole 2019-07-22 23:41:39 +02:00 committed by md_5
parent b0ef3996ed
commit db97147724

View File

@ -66,7 +66,7 @@
@Override @Override
public int getSize() { public int getSize() {
return 1; return 1;
@@ -49,11 +102,18 @@ @@ -49,11 +102,20 @@
} }
@Override @Override
@ -75,7 +75,9 @@
+ public void setItem(int i, ItemStack itemstack) { + public void setItem(int i, ItemStack itemstack) {
+ if (i == 0) { + if (i == 0) {
+ TileEntityLectern.this.setBook(itemstack); + TileEntityLectern.this.setBook(itemstack);
+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook()); + if (TileEntityLectern.this.getWorld() != null) {
+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook());
+ }
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
@ -87,7 +89,7 @@
} }
@Override @Override
@@ -158,6 +218,32 @@ @@ -158,6 +220,32 @@
return itemstack; return itemstack;
} }
@ -120,7 +122,7 @@
private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) { private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) {
String s; String s;
Object object; Object object;
@@ -172,7 +258,8 @@ @@ -172,7 +260,8 @@
Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D); Vec3D vec3d = new Vec3D((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D);
@ -130,7 +132,7 @@
} }
@Override @Override
@@ -211,7 +298,7 @@ @@ -211,7 +300,7 @@
@Override @Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) { public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {