Solved Config Save Issue(When I save a list to config everything else becomes null)

Discussion in 'Spigot Plugin Development' started by Snailz, Jun 5, 2017.

Thread Status:
Not open for further replies.
  1. Hi,
    Basically when I try to save an item to a list in my config by getting the list, adding it, and then putting it back makes it so...

    1: Everything else gets deleted and replaced with {}(https://gyazo.com/886a1b2f4e514917a4ccf93cf957f35f)
    EDIT: PROBLEM 2 SOLVED
    2: The String that I try to save gets saved but not in quotes(https://gyazo.com/65767c02a19aa09c5ad29c3e9fae8360)

    Ill attach the method that I am using below.

    Thanks,
    ~Snailz

    METHOD: https://hastebin.com/yanegibewa.vbs

    GITHUB REPO: https://github.com/SnailKun/RulesConfirm
     
    #1 Snailz, Jun 5, 2017
    Last edited: Jun 6, 2017
  2. Without seeing your onEnable I would guess that you are never writing the config from the jar with saveDefaultConfig(). Like I said thats just a guess without seeing your config set up when the plugin is enabled.
     
  3. I actually do use saveDeafaultConfig().

    Heres my onEnable(): https://hastebin.com/idumoladet.cpp

    Also, if you need to see any of the other code its here(https://github.com/SnailKun/RulesConfirm)
     
  4. The cast to ArrayList is unnecessary, List<String> works just fine - dunno if this causes anything though.
    If you want quotes you need to add them,
    "\"" is a single quote
     
  5. Ok. Ill try that. Any ideas on why it deletes the rest of the config?

    P.S. I cast it to ArrayList because I was desperate lol and i had no idea what to do.
     
  6. Ok. I tried that and it seems like the quotes are being added according the the debug statements but it still deletes everything in the config and now it doesn't add the messages to the list in the first place. I added the new method to the OP.
     
  7. they are being set to null, when doing config.set(path, null) that is what happens
     
  8. So if i do set("questions", some_string_listt) it would set everything in the config to null?
     
  9. You need to put the list back in your config

    Code (Text):
    List<String> list = config.getStringList("whatever");
    list.add("hi");
    config.set("whatever", list);
    //then save
     
  10. no, but somewhere it is setting everything to null
     
  11. Ok. I tried doing this and It put the message with the quotes in quotes.
    EX:
    Code (Text):

    "'message'"
     
     
    • Funny Funny x 1
  12. Have you tried what I suggested?
     
  13. By the way YAML strings only have quotation marks if they contain special characters, so the fact that your lists are missing "" is intended behaviour.
     
  14. Ok. Thanks for telling me lol. That part is fine now. I guess I just thought that it didnt work because of n++ making true and false blue. Do you have any idea why everything else is getting set to null though.

    EDIT: NEVERMIND. I HAVE FIXED THE ISSUE. THANKS FOR TELLING ME ABOUT THE USAGE OF QUOTES.
     
    #14 Snailz, Jun 6, 2017
    Last edited: Jun 7, 2017
    • Like Like x 1
Thread Status:
Not open for further replies.