Config - Getting all values and keys associated with value

Discussion in 'Plugin Development' started by exploder2013, Apr 23, 2014.

Thread Status:
Not open for further replies.
  1. Hey there. I'm trying to create a PVP Arena plugin, but I've run into problem that I want to create a configurable ranks config, butI can't figure out how to get all the values and keys associated with them.

    Example how config is going to look like:
    Code:
    Newbie: 100
    Novice: 250
    Adept: 400
    PRO: 1000
    
    Thanks.
     
  2. Offline

    Wizehh

    If you want to get the number assocatiated with 'Newbie', you'd do something like this (assuming you're using the default configuration file):
    PHP:
    int newbie getConfig().getInt("newbie");
    Or did you want something else? I didn't really understand your question.
     

  3. No, the problem is that my plugin doesn't actually know the values because the whole config file gets filled in by owner of the server. So I need to get all the values without actually knowing their names.
     
  4. Offline

    Wizehh

    Ah, I see. Maybe you can structure your config like this:
    HTML:
    ranks:
        VIP: 100
    
    Then you can iterate over the 'ranks' configuration section.
     
    exploder2013 likes this.

  5. How exactly I would create the "ranks:" in config file, because only thing I found was createSection(String str). And after that how I would iterate through these items inside?

    Thanks.
     
  6. Offline

    coasterman10

    FileConfiguration.getKeys(false);

    No need to restructure the config.
     
    exploder2013 likes this.

  7. Exactly what I was looking for, thanks.
     
Thread Status:
Not open for further replies.

Share This Page