floh
September 10, 2016, 2:22am
1
Hey. Iv’e been trying to get the children map of a node in my config, but trying to get it always returns null, even if children are present.
Method: http://pastebin.com/a0bbTfkD
Config file: http://pastebin.com/jWZshSkN
Now I would think the map would include both “1” and “-1”, as they are both children of Arenas, unless im understanding it completely wrong.
Thanks for your help!
getChildrenMap()
never returns null
, do you mean it returns an empty map?
I think your issue is that getConfig()
is probably the root node, so you don’t need to specify PlayerArenas
in the path.
Try
return getConfig().getNode("Arenas").getChildrenMap();
floh
September 10, 2016, 2:30pm
3
Sorry for my horrible phrasing. Ofcourse i meant an empty map resulting in a NullPointerException when trying to return it since the map is empty. All getConfig() does is returns a CommentedConfigurationNode config.
Here is my full ConfigManager incase it is of any help: http://pastebin.com/5r01JTmF
and the error I get: http://pastebin.com/EQ8PAe9n
setupArenaConfig(int name, UUID uuid) is what adds new nodes to the config. Am I adding them in a way that doesn’t allow childrenMaps?
I bet config
and thus getConfig()
is null. Did you run the setup
method (and not get a stacktrace) before getArenaMap()
?
floh
September 10, 2016, 6:02pm
5
hm ofcourse. I ran setup
on GameStartingServerEvent
and addArenas()
on GamePostInitializationEvent
.
Completely missed that! Moving addArenas()
to GameStartedServerEvent
fixed the issue.
Thank you guys for your help.