Solved How to create lists in config.yml

Discussion in 'Plugin Development' started by MGlolenstine, May 28, 2017.

Thread Status:
Not open for further replies.
  1. Ok, so I'm currently working on a temporary player storage and I need to know how to set it up like this:
    Code:
    players:
        - MGlolenstine
        - Krentm
    so I can read it with
    Code:
    List<String> s = getConfig().get("path")
    If there is another way, please tell me
     
  2. @MGlolenstine
    That is the most common list, it's what YAML will write if you give it a String list, but you can also do the square bracket variant, like this:
    Code:text
    1. players: [MGlolenstine, Krentm]
     
  3. So to edit it programmatically, I have to read it, make changes and then reapply it?
     
  4. @MGlolenstine
    Yes, but you can't write the square bracket format, it'll turn into the first variant.
     
  5. Thank you! Just another question, how can I instantiate List<String>? It says I have to remove arguments.
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    MrGriefer_

    To set it:
    PHP:
    List<StringyourList = new ArrayList<String>();
    getConfig ().set("path"yourList);
     
  8. Ah, ofc... #-_- Thanks once again...

    Closing this thread as solved
     
Thread Status:
Not open for further replies.

Share This Page