Reputation: 1
This is my code. It thinks that the config area section = null.
Heres the code:
public void loadArenas() {
fc1 = new File(plugin.getDataFolder(), "config.yaml");
if (!fc1.exists()) {
try {
fc1.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
}
fc = YamlConfiguration.loadConfiguration(fc1);
for (String keys : fc.getConfigurationSection("Arenas.").getKeys(false)) {
Oh and heres the error:
Upvotes: 0
Views: 299
Reputation: 19506
You should print out the contents of fc1
at the top. It is very likely that you are running into path-related issues and so a new, EMPTY, configuration file is created.
That new file is then used as the input to fc
, and naturally the "Arenas." section wouldn't exist. The NPE would either be thrown when you try to access the non-existent section's keys via getKeys()
.
Either way, if you are not sure what the problem is, you can either step through it with a debugger or just throw print statements everywhere to determine that things are what you expect.
Upvotes: 0