Solved Iterating thru the homes list

Discussion in 'Spigot Plugin Development' started by DeliciousShoesHD, Jul 14, 2016.

  1. Hey guys!

    I just want to know how can I iterate thru a list of homes without making a list named "HomeList" in my configuration. Basically I'd like my plugin to go thru every "Homes.<get_every_this_value>. (and then it continues with parts that aren't important here)". Is it possible to go thru every value like one in <>?
  2. Use FileConfiguration#getKeys()

    Did I help you? Leave a rating
    #2 bys1, Jul 14, 2016
    Last edited: Jul 14, 2016
    • Agree Agree x 1
  3. Code (Text):
    List<String> homes = cfg.getConfigurationSection("Homes").getKeys(false);
    Like that, @bys1 ?
  4. getKeys() returns a Set, so use either
    Code (Java):
    Set<String> homes = cfg.getConfigurationSection("Homes").getKeys(false);
    Code (Java):
    String[] homes = cfg.getConfigurationSection("Homes").getKeys(false).toArray( new String[cfg.getConfigurationSection("Homes").getKeys(false).size()] );

    Did I help you? Leave a rating
  5. Thanks so much!
  6. No problem :)

    Did I help you? Leave a rating