Read a section in a config file

Discussion in 'Plugin Development' started by fafaffy, Feb 11, 2012.

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

    fafaffy

    Is it possible to read a section in a config file
    example:
    Code:
    Example:
        Command1:
        Command2:
        Command3:
    
    would output the values of Command1, Command2, and Command3.
    I tried this, but I don't know how off I am:
    Code:
    for(String msg : plugin.config.getStringList("Example")){
    //code
    }
    Nvm, got it.

    Code:
    for(String Commands : config.getConfigurationSection("").getKeys(false)){
     
    }
     
  2. Offline

    sds

    You could use a list:
    Code:
    List<String> commands;
    commands = plugin.config.getStringList("commands");
    
    Then you have all the commands in one list...
    Your config will look like this:
    Code:
    commands:
    - "command 1"
    - "command 2"
    - "command 3"
    
     
  3. Offline

    fafaffy

    Yeah, I already did that (Forgot to update the thread). The reason I needed the sections was to know which commands are there (Ex: Example, AnotherSecretWord, etc...). The commands, however, are in a list. Thanks for your suggestion/helping me, though. I appreciate it.
     
Thread Status:
Not open for further replies.

Share This Page