MalformedJsonException

Discussion in 'Plugin Development' started by RoboticPlayer, Oct 11, 2015.

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

    RoboticPlayer

    I haven't used JSON text in a while, and I would like to know why this isn't working. I am trying to play a title packet, but there is something wrong with it.
    Code:java
    1. private PacketPlayOutTitle blacklistTitle = new PacketPlayOutTitle(EnumTitleAction.TITLE,
    2. ChatSerializer.a("{\"text\":\"[\",\"color\":\"gray\",\"italic\":true},
    3. {\"text\":\"AutoInv\",\"color\":\"red\",\"underlined\":true,\"italic\":false},
    4. {\"text\":\"]\",\"color\":\"gray\",\"italic\":true,\"underlined\":false},
    5. {\"text\":\"This item is blacklisted!\",\"color\":\"gray\",\"italic\":true}"),
    6. 10, 30, 10);
     
  2. Offline

    rbrick

    @henderry2019
    There can only be one "text" tag/key in the chat object. Everything else would need to be put into an "extra" tag/key (which is an array)

    http://wiki.vg/Chat
     
  3. Offline

    RoboticPlayer

    @rbrick How would I use the extra key? Can you give an example of how it would be used with a text key as I have it now? I tried changing it but I didn't really understand from the link you gave me how to use the extra tag.
    Code:java
    1. private PacketPlayOutTitle blacklistTitle = new PacketPlayOutTitle(EnumTitleAction.TITLE,
    2. ChatSerializer.a("{\"text\":\"[\",\"color\":\"gray\",\"italic\":true},
    3. {\"extra\":\"AutoInv\",\"color\":\"red\",\"underlined\":true,\"italic\":false},
    4. {\"extra\":\"]\",\"color\":\"gray\",\"italic\":true,\"underlined\":false},
    5. {\"extra\":\"This item is blacklisted!\",\"color\":\"gray\",\"italic\":true}"),
    6. 10, 30, 10);
     
Thread Status:
Not open for further replies.

Share This Page