Adding a string to a list in a yml config

Discussion in 'Plugin Development' started by willeb96, Nov 25, 2012.

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

    willeb96

    Hey guys!

    Any idea why this is adding null to my list?
    Code:
    getConfig().getStringList("path.list").add("TEST_VALUE");
    Thanks :)
     
  2. Offline

    ZeusAllMighty11

    You can do

    Code:
    getConfig().add("path.list", "TEST_VALUE");
    
    still works[/code]
     
  3. Offline

    willeb96

    That didn't work :(
     
  4. Offline

    ZeusAllMighty11

    It works for me. Show what doesn't work. Errors? Red lines? Just nothing? Post code of your config
     
  5. Offline

    willeb96

    [​IMG]
     
  6. Offline

    ZeusAllMighty11

    Sorry try Main.plugin.getConfig().set("completed-quests.miner", player.getName());
     
  7. Offline

    willeb96

    That doesn't seem to work either, I get nothing in my config...

    Code:
    completed-quests:
      miner:
        -
    
    (I added the dash manually before I ran the code to make sure it's a list)

    Just noticed that .set() will remove the list and store as a string instead.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  8. Offline

    fireblast709

    you should get the list, add it, and then set it to the updated list (and save!)
     
    willeb96 likes this.
  9. Offline

    willeb96

    Thanks! Works perfectly :D
     
Thread Status:
Not open for further replies.

Share This Page