YML loading difficulty

Discussion in 'Plugin Development' started by nuclearmissile, Dec 28, 2014.

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

    nuclearmissile

    I've only used YML files for a short time and don't yet understand their complexities, but I still usually manage to figure out what I'm doing wrong by myself. This is not one of those times:

    Code:
    if(protectionDat.contains("shieldLocations")){
                Set<String> s = getConfig().getConfigurationSection("shieldLocations").getKeys(false);
                String[] ss = (String[])s.toArray();
                for(int i = 0; i < ss.length; i++){
                    shieldLocs.add(locConvert(ss[i]));
                }
            }
    The following line is throwing a null pointer exception:

    Set<String> s = getConfig().getConfigurationSection("shieldLocations").getKeys(false);

    I have no idea why it's happening, I have similar code in other plugins and it doesn't throw an NPE. Any help is appreciated.
     
  2. Offline

    Skionz

    @nuclearmissile There is no 'shieldLocations.' What is 'protectionDat?' It looks like your checking if it contains shieldLocations, but then you get the set from the default config.
     
  3. Offline

    nuclearmissile

    @Skionz
    shieldLocations is just the header of the file
    protectionDat is the name of the YAMLConfiguration object
    so how do I get it from the right file instead of default config?

    Nevermind, I got it working. Now I feel pretty stupid, but thanks for knocking some sense into me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 31, 2016
Thread Status:
Not open for further replies.

Share This Page