Get all possible branches from yml config.

Discussion in 'Plugin Development' started by Randy Schouten, Oct 26, 2011.

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

    Randy Schouten

    So let's say the config looks like:
    Code:
    players:
        herp: 1
        derp: 2
        flerp: 3
    Is there a way to get herp, derp and flerp in one list/array?
    Thanks in advance ;)
     
  2. I'm not 100% sure but I think this can do it.
     
  3. Offline

    Randy Schouten

    That is what I want and what I found earlier, except not in the root. :p
    I want to get everyone in "players".
     
  4. Offline

    Windwaker

    Code:java
    1. getConfig().getList("players");
     
  5. Offline

    Randy Schouten

    Nope.

    That's more like a "getString("something")" method.
    Thanks anyway :)
     
  6. Offline

    Windwaker

    Err... no it's not.
    Code:java
    1. getConfig().getString("path.to.string");

    Would get you:
    Code:
    path:
      to:
        string: This is what would be returned
    Code:java
    1. getConfig().getString("path.to.list");

    Would get you:
    Code:
    path:
      to:
        list:
          - This
          - Would
          - Be
          - Returned
    Unless I have misunderstood your question.
     
  7. Offline

    DDoS

    getKeys(false) will do the job. But, you'll have to grab the section in which herp, derp and flerp are located.

    Try this:

    Code:
    FileConfiguration config = getConfig();
    
    Set<String> players = config.getConfigurationSection("players").getKeys(false);
     
  8. Offline

    Randy Schouten

    Okay, I'll say exactly what I want to do.

    Code:
    users:
        derp:
            permissions:
                permissions.example: true
            groups:
            - admin
       herp:
            permissions:
                permissions.example: true
            groups:
            - admin
        flerp:
            permissions:
                permissions.example: true
            groups:
            - admin
    That's what the PermissionsBukkit file looks like.
    I want to get all the users in the file, nothing more, nothing less.

    So as the output here, I want "derp, herp, flerp".
    I hope you understand what I mean. ;)

    EDIT: Thank you DDoS. :D
    That's exactly what I was looking for.

    Previously I was looking for something such as "setRoot("users")" or something.
     
  9. Offline

    Windwaker

    Oh, I did misunderstand, my mistake. :rolleyes:
     
  10. Offline

    Randy Schouten

    Haha, no problem.
    Thanks for the effort. :)
     
Thread Status:
Not open for further replies.

Share This Page