` public static void openBook(ItemStack book, Player p) {
int slot = p.getInventory().getHeldItemSlot();
ItemStack old = p.getInventory().getItem(slot);
p.getInventory().setItemInMainHand(book);
ByteBuf buf = Unpooled.buffer(256);
buf.setByte(0, slot);
buf.writerIndex(1);
PacketPlayOutOpenBook packet = new PacketPlayOutOpenBook(EnumHand.MAIN_HAND);
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
System.out.println("sent");
p.getInventory().setItem(slot, old);
}
@SneakyThrows
public static ItemStack makeBook(String title, String author, String[] text) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
for (String page : text) {
meta.addPage(page);
}
meta.setTitle("Example");
meta.setAuthor("Server");
book.setItemMeta(meta);
return book;
}`
` public static void openBook(ItemStack book, Player p) { int slot = p.getInventory().getHeldItemSlot(); ItemStack old = p.getInventory().getItem(slot); p.getInventory().setItemInMainHand(book);
makeBook method is pog, fixed tablist aswell.