Getting multiple subvalues in a config

Discussion in 'Plugin Development' started by Taco, Mar 24, 2012.

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

    Taco

    If I have a config as shown below

    main:
    'sub1': turtles​
    'sub2': bleh​
    'sub3': morevalues​

    How do I get a list of all those values? I want a list that would contain, in this example, "turtles, bleh, morevalues".
     
  2. getKeys("main") would give you a list of the keys and values from "main".

    EDIT: I guess they changed how getKeys() is called, see below post.
     
  3. Code:
    List<String> subvaules = new ArrayList<String>();
    Set<String> keys = getConfig().getConfigurationSection("main").getKeys(false);
    for(Sting key : keys)
    {
      subvalues.add(getConfig().get("main." + key));
    }
    should work.
     
    zippy120 and Taco like this.
  4. Offline

    Taco

    This is precisely what I needed. Thank you!
     
Thread Status:
Not open for further replies.

Share This Page