Add spacing in lectern Spigot get code

This commit is contained in:
Camotoy 2021-03-08 16:59:59 -05:00
parent da11cd298c
commit ad4196f5a0
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 4 additions and 0 deletions

View File

@ -187,11 +187,13 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) {
return;
}
Block block = bukkitPlayer.getWorld().getBlockAt(x, y, z);
if (!(block.getState() instanceof Lectern)) {
session.getConnector().getLogger().error("Lectern expected at: " + Vector3i.from(x, y, z).toString() + " but was not! " + block.toString());
return;
}
Lectern lectern = (Lectern) block.getState();
ItemStack itemStack = lectern.getInventory().getItem(0);
if (itemStack == null || !(itemStack.getItemMeta() instanceof BookMeta)) {
@ -202,6 +204,7 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
// We don't care; return
return;
}
BookMeta bookMeta = (BookMeta) itemStack.getItemMeta();
// On the count: allow the book to show/open even there are no pages. We know there is a book here, after all, and this matches Java behavior
boolean hasBookPages = bookMeta.getPageCount() > 0;
@ -226,6 +229,7 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
.putString("text", "");
pages.add(pageBuilder.build());
}
bookTag.putCompound("tag", NbtMap.builder().putList("pages", NbtType.COMPOUND, pages).build());
lecternTag.putCompound("book", bookTag.build());
NbtMap blockEntityTag = lecternTag.build();