Reputation: 13
simpleco:
expenses: 100
revenue: 150
How do I call on the node "simpleco"? I am making a bukkit plugin and i need to be able to call on this. The file format is yml/Yaml. Thanks :)
Upvotes: 1
Views: 287
Reputation: 18834
Bukkit has the method getKeys(false)
, that you can call on a ConfigurationSection
to get all nodes inside it. The usage of this api is simple:
public class MyPlugin extends JavaPlugin {
public void onEnable(){
Set<String> keys = this.getConfig().getConfigurationSection("simpleco").getKeys(false);
}
}
The set called keys
will now contain expenses
and revenue
.
You can then do a for loop over it so you can read all the things:
ConfigurationSection sec = this.getConfig().getConfigurationSection("simpleco")
Set<String> keys = sec.getKeys(false);
for(String key : keys) {
int value = sec.getInt(key);
System.out.println(key + "=" + value);
}
Upvotes: 3