From bbe3d58efc489ce7905d4334dba82426e36610b8 Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Apr 2020 09:30:47 +1100 Subject: [PATCH] SPIGOT-5650: Lectern.setPage(int) causes a NullPointerException --- nms-patches/TileEntityLectern.patch | 9 +++++++++ .../org/bukkit/craftbukkit/block/CraftLectern.java | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/nms-patches/TileEntityLectern.patch b/nms-patches/TileEntityLectern.patch index ee37d5fb56..a067727b00 100644 --- a/nms-patches/TileEntityLectern.patch +++ b/nms-patches/TileEntityLectern.patch @@ -89,6 +89,15 @@ } @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 @@ return itemstack; } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java index bb57b750be..eb6b6a6dcf 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLectern.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.block; +import net.minecraft.server.BlockLectern; import net.minecraft.server.TileEntityLectern; import org.bukkit.Material; import org.bukkit.block.Block; @@ -40,4 +41,15 @@ public class CraftLectern extends CraftBlockEntityState imple 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; + } }