-
Type:
Bug
-
Resolution: Invalid
-
Priority:
Minor
-
None
-
Affects Version/s: None
-
Environment:
n/a
-
This server is running CraftBukkit version 3114-Spigot-66f9d3c-6fdecf2 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
-
Yes
A lectern, when spawned and given a book, will never display the book, despite the inventory reporting it is not an empty LecternInventory.
Spigot forum threads declare adding a book is only possible via NMS, as there is no lectern.setHasBook();
The below code will show my findings in the matter, just insert your own player.
Player player =
// Creating the Book.
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
meta.setTitle("title");
meta.setAuthor("author");
meta.addPage("page");
book.setItemMeta(meta);
// Making the lectern.
Block block = Bukkit.getWorld("world").getBlockAt(player);
block.setType(Material.LECTERN, true);
// Putting the book in the lectern. (Fails)
org.bukkit.block.Lectern lectern = (Lectern) block.getState();
lectern.getInventory().addItem(book); // Neither work;
lectern.getInventory().setItem(0, book);
lectern.update(true);
System.out.println("size = " + lectern.getInventory().getSize()); // size will show 1
System.out.println("isEmpty = " + lectern.getInventory().isEmpty()); // isEmpty will report false.
// The lectern block never shows a book despite the above code.