Opening book through ProtocolLib on Spigot 1.12.2

Discussion in 'Spigot Help' started by Chaoscrasher, Feb 4, 2020.

  1. So my aim is to show a book gui to a player when needed.

    I'm using this code:
    Code (Java):
    public static void openBook(ItemStack book, Player p)
    {
            ProtocolManager pm = ProtocolLibrary.getProtocolManager();
            int slot = p.getInventory().getHeldItemSlot();
            ItemStack old = p.getInventory().getItem(slot);
            p.getInventory().setItem(slot, book);
            PacketContainer pc = pm.createPacket(PacketType.Play.Server.OPEN_BOOK);
            try
            {
                pm.sendServerPacket(p, pc);
            } catch (InvocationTargetException e)
            {
                throw new RuntimeException("Cannot send open book packet " + pc, e);
            }
            p.getInventory().setItem(slot, old);
    }
    Unfortunately I'm getting the following error:

    Code (Text):
    java.lang.IllegalArgumentException: Cannot find associated packet class: OPEN_BOOK[PLAY, SERVER, 46, classNames: net.minecraft.server.v1_12_R1.PacketPlayOutOpenBook] (unregistered)
     
    On further inspection this packet class indeed does not seem to exist in the 1.12.2-craftbukkit.-jar

    Is there any way to do this on 1.12.2?