Question Yaml-file 2 values under one

Discussion in 'Plugin Help/Development/Requests' started by ScorixEar, Jun 15, 2015.

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

    ScorixEar

    Hi guys and girls,
    my question is, how can i save more than one value at one heading in a yml-file:
    Code:
    //YAML_FILE
    test:
      first heading:
        - first value
        - second value
    @I Al Istannen ;D
     
  2. Offline

    I Al Istannen

    @ScorixEar You could save a List . Depends on what you want to achieve.
     
  3. Offline

    ScorixEar

  4. Offline

    I Al Istannen

    @ScorixEar I think easier to understand than words:
    Code:
    List<UUID> list = new ArrayList<>(); // should be possible with any list, I tested with ArrayList
    this.getConfig().set("Test Path", list);
    
    this.getConfig().getList("Test Path"); // retrieve
    
     
  5. Offline

    ScorixEar

    So in the end there stand in the yml file this?
    Code:
    TestPath:
       - test1
       - test2
       - test3
     
  6. Offline

    I Al Istannen

    @ScorixEar I would go for: try it :) But as far as I know, yes. But again, just try it with different objects. What I don't know is, if they have to be "ConfigurationSerializable". You will have to try, if you need it.
     
  7. Offline

    Europia79

    @ScorixEar

    From what I've seen, there are several different list formats that are acceptable yaml syntax:

    Code:
    List1: [value1, value2]
    Code:
    List2:
    - value1
    - value2
    Code:
    List3:
      - value1
      - value2
    Code:
    List4:
        - value1
        - value2
    So, you can use any of these formats if you're editing by hand (or if you're including a default config.yml): Just be consistent.

    Also, take note, that his code for getConfig().set("Test Path", list); would most likely result in something like this:
    Code:
    'Test Path': []
     
Thread Status:
Not open for further replies.

Share This Page