1.16.5 Book item back to json?

Discussion in 'Spigot Plugin Development' started by VergilPrime, Oct 12, 2020.

  1. I'm just trying to confirm what I've come across by searching as sometimes people think a thing is impossible but it's really not.

    You can't take a written book item and jet the raw json out of it? There's always data lost when using json to generate a book? So there's no possible way to say, copy a book text including hex colors, urls etc into an unwritten book for the purpose of updating it? I find this absolutely wild, can someone confirm or deny?
     
  2. I believe that so far, it is not possible to make.
     
  3. Looking at javadocs i found BookMeta that contains all the informations of a book: title, author, text.
    Code (Java):
    // This get all the text of a page
    bookMeta.getPage(pageNumber);

    // This get all the pages and store them into a List<String>
    bookMeta.getPages();

    But i'm not sure if the text contains the colors and urls, I have never played around with books, i'll test it later.
     
  4. You could try to use Gson. E.g new Gson().toJson(book) returns string with the book as json. There's more things you can do with gson, but you have to figure it out yourself.