Bukkit getting config list of variables

Discussion in 'Plugin Development' started by augustas656, Sep 17, 2014.

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

    augustas656

    What methods from MemorySection, e.g.: getString, getList, getStringList etc, do I use to get a list of string keys with string values. To show an example config:

    Code:
    example:
    - eg1: "example message, test"
    - eg2: "example 123"
    - eg3: "abcdefghijklmnopqrstuvwxy"
    - eg4: "123456 example, message"
    What methods do I use to get a Map, Array or ArrayList of the keys, eg1, eg2, eg3, eg4 and with them their values? getList or? A good example for me could be how to make a loop and print each key and value.

    Regards
    augustas656
     
  2. Offline

    Garris0n

    Code:
    ConfigurationSection exampleSection = config.getConfigurationSection("example");
    List<String> keys = exampleSection.getKeys(false);
     
  3. Offline

    augustas656

    I want to get keys and values?
     
  4. Offline

    Garris0n

  5. augustas656
    It looks like you're trying to use a stringlist with keys and values, however it doesn't work like that unless you implement your own system to get and parse the values by keys.

    Garris0n 's code would return all keys in a configurationsection:
    Code:
    example:
      key1: something
      key2: somethingelse
    in this case would return "key1" and "key2". You can use these keys to fetch their representing values.
     
Thread Status:
Not open for further replies.

Share This Page