SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException

This commit is contained in:
md_5 2020-04-01 09:30:47 +11:00
parent 3075579f61
commit bbe3d58efc
2 changed files with 21 additions and 0 deletions

View File

@ -89,6 +89,15 @@
} }
@Override @Override
@@ -135,7 +197,7 @@
if (j != this.page) {
this.page = j;
this.update();
- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock());
+ if (this.world != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
}
}
@@ -158,6 +220,32 @@ @@ -158,6 +220,32 @@
return itemstack; return itemstack;
} }

View File

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.block; package org.bukkit.craftbukkit.block;
import net.minecraft.server.BlockLectern;
import net.minecraft.server.TileEntityLectern; import net.minecraft.server.TileEntityLectern;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -40,4 +41,15 @@ public class CraftLectern extends CraftBlockEntityState<TileEntityLectern> imple
return new CraftInventoryLectern(this.getTileEntity().inventory); return new CraftInventoryLectern(this.getTileEntity().inventory);
} }
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result && this.isPlaced() && this.getType() == Material.LECTERN) {
BlockLectern.a(this.world.getHandle(), this.getPosition(), this.getHandle());
}
return result;
}
} }