From 13c924f841c95b69bc75212550191a914e213467 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Fri, 26 Feb 2021 00:54:05 -0500 Subject: [PATCH] Make lecterns more reliable on chunk load in Spigot --- .../spigot/world/manager/GeyserSpigotWorldManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java index 25546a3ad..99dbc7763 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java @@ -182,7 +182,7 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager { @Override public NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad) { // Run as a task to prevent async issues - Bukkit.getScheduler().runTask(this.plugin, () -> { + Runnable lecternInfoGet = () -> { Player bukkitPlayer; if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) { return; @@ -220,7 +220,13 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager { lecternTag.putCompound("book", bookTag.build()); NbtMap blockEntityTag = lecternTag.build(); BlockEntityUtils.updateBlockEntity(session, blockEntityTag, Vector3i.from(x, y, z)); - }); + }; + if (isChunkLoad) { + // Delay to ensure the chunk is sent first, and then the lectern data + Bukkit.getScheduler().runTaskLater(this.plugin, lecternInfoGet, 5); + } else { + Bukkit.getScheduler().runTask(this.plugin, lecternInfoGet); + } return LecternInventoryTranslator.getBaseLecternTag(x, y, z, 0).build(); // Will be updated later }