Solved Open Book without clicking 1.9

Discussion in 'Spigot Plugin Development' started by Litona, May 14, 2016.

Thread Status:
Not open for further replies.
  1. Hii devs!
    I want to open a book, but I don't want the player to be in need to click the book.
    I found a solution for this in Spigot 1.8, but now it's no longer working(Spigot 1.9, 1.9.2, 1.9.4). The player recives the book, but the book is just not opened.
    Code (Text):
    private void openBook(final ItemStack book, final UUID uuid) {
            final Player p = Bukkit.getServer().getPlayer(uuid);
            final int slot = p.getInventory().getHeldItemSlot();
            final ItemStack old = p.getInventory().getItem(slot);
            p.getInventory().setItem(slot, book);
            p.updateInventory();
            new BukkitRunnable() {
                @Override
                public void run() {
                    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|BOpen", new PacketDataSerializer(Unpooled.EMPTY_BUFFER)));
                    //p.getInventory().setItem(slot, old);
                }
            }.runTaskLater(Main.getPlugin(Main.class), 15);
        }
    In this thread I found a possible solution for 1.9, but even that isn't working :(

    Has anyone of you got an idea how I can open the book without the player needing to click it?
    -Litona
     
  2. I basically just googled "minecraft bopen 1.9", it was the first link to show up for me.
     
Thread Status:
Not open for further replies.