Bukkit Config troubles

Discussion in 'Plugin Development' started by Cosmicluck, May 22, 2016.

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

    Cosmicluck

    I have had a lot of trouble with configs in the past, and apparently today is no exception. All i'm trying to do is get the "Events" from the config example below. Basically I want to send the player a message containing the names of all the Events from this config. So in this case, the player should have a message containing "Test, Test2". However no matter what I try, it refuses to work.

    I have tried using these methods:

    Code:
    List<String> events = getConfig().getStringList("Events");
    Code:
    for (String key : ec.getConfig().getConfigurationSection("Events").getKeys(false)) {
         p.sendMessage("" + key);
    }
    Code:
    Events:
      Test:
        - Head1
        - Head2
      Test2:
        - Head1
        - Head2
    They either return nothing in the player's message, or in the case of the second method, gives me a nullpointerexception.

    I have never been good with configs, even after reading the configuration API multiple times. If anyone can help me out, it would be much appreciated!

    Note: ec.getConfig() is my custom config file specifically for the "Events".
     
  2. Offline

    Zombie_Striker

    @Cosmicluck
    If you look at the docs (here), by setting "deep" to false, you are only trying to get all paths inside "events". Try setting "deep" equal to true.
     
Thread Status:
Not open for further replies.

Share This Page