I am using Bukkit API 1.8.3
I have this piece of code:
for(String vey : main.getConfig().getConfigurationSection("shopitems."+key+".enchantments").getKeys(false))
{
Enchantment ench = Enchantment.getByName(vey);
int level = main.getConfig().getInt("shopitems."+key+".enchantments."+vey);
meta.addEnchant(ench, level, true);
}
This piece of code gives me a nullpointer pointing to the line that starts the for-loop iteration.
To try to fix this I have a Null checker:
if(main.getConfig().getConfigurationSection("shopitems."+key+".enchantments").getKeys(false)!=null)
After this null checker I then put the code above inside this if statement.
However I am getting a nullpointer on the line that is testing if that path is null
My question: Why is this not working and how can I fix it
NOTE: main.getConfig() which returns the FileConfiguration is not null I have tested an debugged this