Solved How to add an array list in config.yml using addDefault()?

Discussion in 'Spigot Plugin Development' started by Creatos137, Apr 24, 2017.

  1. Hey,

    So I wondering how you can add an array list in the conifg file using .getConfig().addDefault()?

    Thank you for helping
    - Creatos
  2. You can iterate over the items in the list if they're strings or something that would uniquely identify them such as a uuid then save them to the config as individual values, or one string separated by commas, or if the items are serializable you can write them in and reload them directly.

    It kind of depends on what type of object is in the list you're trying to save.

    Sent from my iPhone using Tapatalk
  3. I am making a list like this:

    Code (Text):
      - Name 1
      - Name 2
      - Name 3
  4. Then a simple for loop that writes in the configuration as a string will suffice.
    for(string name:yourList)

    Or another solution

    Sent from my iPhone using Tapatalk
  5. Thank you, this helped!