@@ -0,0 +1,1456 @@
+package cat.nyaa.nyaacore.utils;%0A%0Aimport net.minecraft.server.v1_13_R2.EntityPlayer;%0Aimport net.minecraft.server.v1_13_R2.EnumHand;%0Aimport net.minecraft.server.v1_13_R2.PacketPlayOutSetSlot;%0Aimport org.bukkit.Material;%0Aimport org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;%0Aimport org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;%0Aimport org.bukkit.entity.Player;%0Aimport org.bukkit.inventory.ItemStack;%0A%0Apublic class PlayerUtils %7B%0A    public static void openWrittenBook(Player player, ItemStack book) %7B%0A        if (book != null && book.getType() == Material.WRITTEN_BOOK) %7B%0A            sendFakeItemStack(player, player.getInventory().getHeldItemSlot(), book);%0A            ((CraftPlayer) player).getHandle().a(CraftItemStack.asNMSCopy(book), EnumHand.MAIN_HAND);%0A            player.updateInventory();%0A        %7D%0A    %7D%0A%0A    public static void sendFakeItemStack(Player p, int index, ItemStack itemStack) %7B%0A        EntityPlayer player = ((CraftPlayer) p).getHandle();%0A        if (player.playerConnection == null) %7B%0A            return;%0A        %7D%0A        if (index %3C net.minecraft.server.v1_13_R2.PlayerInventory.getHotbarSize()) %7B%0A            index += 36;%0A        %7D else if (index %3E 39) %7B%0A            index += 5;%0A        %7D else if (index %3E 35) %7B%0A            index = 8 - (index - 36);%0A        %7D%0A        player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.defaultContainer.windowId, index, CraftItemStack.asNMSCopy(itemStack)));%0A    %7D%0A%7D%0A

support open written book NyaaCat/NyaaUtils#56