Get how many children a section has.

Discussion in 'Plugin Development' started by TheGamesHawk2001, Jun 19, 2015.

Thread Status:
Not open for further replies.
  1. Hey all,

    how would I get how many children a section has in a config.

    Say,

    kits:
    member:
    - GRASS
    pvp:
    - DIAMOND_SWORD

    this would return 1 because there's 2 children (member and pvp)
     
  2. Offline

    Drkmaster83

    ...Ah, what? Why return 1?

    I believe you're looking for ConfigurationSection#getKeys(false).size(), perhaps?
     
  3. because there's 2 children (member and pvp)
     
  4. Offline

    Drkmaster83

    But 1 != 2. Are we doing some zero-based stuff or something?
     
  5. it's an array i think, 0 == 1, 1 == 2 etc
     
  6. Offline

    Drkmaster83

    What I suggested returns a Set, which you can invoke Set#size() on, so therefore, it is not zero-based (if I'm getting what you desire correct, at least).
     
  7. Zero-based is only for indexes (accessing something at index x). .size(), .length are returning the actual number of how many objects there are
     
  8. yes, I want to get the path name at a certain child index. e.g.


    kits:
    member



    I would want to get the string "member" at the index 0
     
Thread Status:
Not open for further replies.

Share This Page