[1.12.2] Turning config nodes into a list


#1

I am trying to get all of the nodes of the config, and turn them into a string list.

for example:

"node" {
    Name="Elrol"
    X=-241
    Y=66
    Z=324
},
"node-2" {
    Name="Eyno"
    X=-0
    Y=80
    Z=160
}

would return a list of strings that only have “node” and “node-2”

Any help would be greatly appreciated.


#2

I’d do it with something like this
config

"root": {
  "alpha": {...},
  "beta": {...}
}

java

ConfigurationNode cfg = loader.load();
List<String> keysInRoot = cfg.getNode("root").getChildrenMap() //all key -> value pairs in "root"
    .keySet().stream() //get a stream over all keys
    .map(Object::toString) //because the child map is Object -> Configuration Node
    .collect(Collectors.toList()); //you could also collect to a set

#3

Giving it a go now. Thanks for the response.