Using NBTTagCompound to set pages?

Discussion in 'Plugin Development' started by Blockhead7360, Dec 24, 2016.

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

    Blockhead7360

    Hello!

    I am trying to set pages with an NBTTagCompound (because I need clickable and hoverable text). Here is the code for a TEST version (there isn't any clickable test in here, and it still doesn't work):

    Code:
    NBTTagCompound tag = new NBTTagCompound();
            tag.setString("author", "Blockhead7360");
            tag.setString("title", ChatColor.GREEN + "" + ChatColor.BOLD + "Book");
            tag.setString("pages", "[\"{\\\"text\\\":\\\"Test\\\"}\"]");
    The author and title show up, but the pages do not. Is there something wrong with my JSON formatting?

    P.S. I've never used NBT in Bukkit/Spigot before so I'm probably making a dumb mistake.
     
    Last edited: Dec 24, 2016
  2. Offline

    I Al Istannen

    @Blockhead7360
    Maybe this helps?
    Code:
    NBTTagCompound{
        map={
            pages=NBTTagList{
                list=[
                    NBTTagString{
                        string='{
                            text:"Click, page 1",
                            clickEvent:{
                                action:run_command,
                                value:"/say Clicked page 1"
                            }
                        }'
                    },
                    NBTTagString{
                        string='{
                            text:"Click, page 2",
                            clickEvent:{
                                action:run_command,
                                value:"/say Clicked page 2"
                            }
                        }'
                    }
                ]
            },
            author=NBTTagString{
                string=''
            },
            title=NBTTagString{
                string=''
            }
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page