Books feed with json

Discussion in 'Plugin Development' started by tfacchini, Jun 30, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    tfacchini

    Does anyone know if it's possible to feed book content with JSON content through any bukkit method such as setPage or setItemMeta or something else?

    I'm trying to create a friendly interface for my plugins.

    Like this guy is doing here:


    Thanks in advance,
    TF
     
  2. It's possible:
    Code:
    ItemStack book = new ItemStack(Material.BOOK); //Create bukkit book
    net.minecraft.server.v1_8_R2.ItemStack stack = CraftItemStack.asNMSCopy(book); //Get the nms version
    NBTTagCompound tag = new NBTTagCompound(); //Create the NMS Stack's NBT (item data)
    tag.setString("title", "someBookTitle"); //Set the book's title
    tag.setString("author", "someAuthor"); //Set the book's author
    NBTTagList pages = new NBTTagList();
    pages.add(new NBTTagString("{text:\"Hello there!\",color:blue}")); //Add a page, note: has to be within quotes and you need to escape inside quotes with a backslash
    pages.add(new NBTTagString("{text:\"Another page :O\"}"));
    tag.set("pages", pages); //Add the pages to the tag
    stack.setTag(tag); //Apply the tag to the item
    ItemStack is = CraftItemStack.asCraftMirror(stack); //Get the bukkit version of the stack
    doSomeStuffWithThisItemStack(is);
    Note: Requires CraftBukkit/Spigot server, not Bukkit or Spigot API as library
     
    tfacchini, FisheyLP and KingFaris11 like this.
  3. Offline

    mkezar

    I believe this can be marked as solved. @tfacchini
     
    tfacchini likes this.
  4. Offline

    tfacchini

    Guys you f*cking awesome!

    It open so many alternatives for systems / ui's
     
Thread Status:
Not open for further replies.

Share This Page