3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +01:00

Add spacing in lectern Spigot get code

Dieser Commit ist enthalten in:
Camotoy 2021-03-08 16:59:59 -05:00
Ursprung da11cd298c
Commit ad4196f5a0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -187,11 +187,13 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) { if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) {
return; return;
} }
Block block = bukkitPlayer.getWorld().getBlockAt(x, y, z); Block block = bukkitPlayer.getWorld().getBlockAt(x, y, z);
if (!(block.getState() instanceof Lectern)) { if (!(block.getState() instanceof Lectern)) {
session.getConnector().getLogger().error("Lectern expected at: " + Vector3i.from(x, y, z).toString() + " but was not! " + block.toString()); session.getConnector().getLogger().error("Lectern expected at: " + Vector3i.from(x, y, z).toString() + " but was not! " + block.toString());
return; return;
} }
Lectern lectern = (Lectern) block.getState(); Lectern lectern = (Lectern) block.getState();
ItemStack itemStack = lectern.getInventory().getItem(0); ItemStack itemStack = lectern.getInventory().getItem(0);
if (itemStack == null || !(itemStack.getItemMeta() instanceof BookMeta)) { if (itemStack == null || !(itemStack.getItemMeta() instanceof BookMeta)) {
@ -202,6 +204,7 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
// We don't care; return // We don't care; return
return; return;
} }
BookMeta bookMeta = (BookMeta) itemStack.getItemMeta(); 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 // 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; boolean hasBookPages = bookMeta.getPageCount() > 0;
@ -226,6 +229,7 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
.putString("text", ""); .putString("text", "");
pages.add(pageBuilder.build()); pages.add(pageBuilder.build());
} }
bookTag.putCompound("tag", NbtMap.builder().putList("pages", NbtType.COMPOUND, pages).build()); bookTag.putCompound("tag", NbtMap.builder().putList("pages", NbtType.COMPOUND, pages).build());
lecternTag.putCompound("book", bookTag.build()); lecternTag.putCompound("book", bookTag.build());
NbtMap blockEntityTag = lecternTag.build(); NbtMap blockEntityTag = lecternTag.build();