Making a list of strings.

Discussion in 'Plugin Development' started by the_merciless, Feb 27, 2013.

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

    the_merciless

    I currently have a file set out like this for each player:

    Code:
    Perks:
        Example1: true
        Example2: false
        Example3: true
        Example4: true
    How do i get each true "example" and add it to a string list, so i can send a messsage to a player along the lines of..

    "Currently activated perks: Example1, Example3, Example4"
     
  2. Offline

    Rprrr

    Code:
            List<String> activatedPerks = new ArrayList<String>();
            for (String keyString : getConfig().getConfigurationSection("Perks").getKeys(false)){
                if (getConfig().getBoolean("Perks." + keyString) == true){
                    activatedPerks.add(keyString);
                }
            }
     
  3. Offline

    the_merciless

    Thanks, What does '(false)' do?
     
  4. Offline

    Ne0nx3r0

  5. Offline

    Rprrr

    the_merciless
    Set<String> org.bukkit.configuration.ConfigurationSection.getKeys ( boolean deep )
    Gets a set containing all keys in this section.
    If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc). These will be in a valid path notation for you to use.
    If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
     
  6. Offline

    the_merciless

    Thanks for the help :)
     
Thread Status:
Not open for further replies.

Share This Page