Facebook
From Wet Lion, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 63
  1.     public static void openDiscordLinkMenu(Player p) {
  2.         ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
  3.         BookMeta bookMeta = (BookMeta) book.getItemMeta();
  4.         List<String> pages = new ArrayList<String>();
  5.         UUID id = UUID.randomUUID();
  6.  
  7.         bookMeta.setTitle("Nieuws");
  8.         bookMeta.setAuthor("Djorr");
  9.         bookMeta.setPages(pages);
  10.  
  11.  
  12.         book.setItemMeta(bookMeta);
  13.  
  14.  
  15.         int slot = p.getInventory().getHeldItemSlot();
  16.         ItemStack old = p.getInventory().getItem(slot);
  17.         p.getInventory().setItem(slot, book);
  18.  
  19.         ByteBuf buf = Unpooled.buffer(256);
  20.         buf.setByte(0, (byte) 0);
  21.         buf.writerIndex(1);
  22.  
  23.         PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload("MC|BOpen", new PacketDataSerializer(buf));
  24.         ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
  25.         p.getInventory().setItem(slot, old);
  26.  
  27.     }