Get all nodes, that this node has as parent

Discussion in 'Plugin Development' started by xZise, Apr 2, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    xZise

    Hello,
    how could I get all nodes, that are in a specific node? For example I have following file:
    Code:
    foo:
      hallo:
        - 10
      world:
        - 42
    bar:
      bukkit:
        craft:
          - 1337
    Now I have the root node, and want to have the foo and bar node (and I have to know the name of the node). Is it not possible with Configuration?

    Fabian
     
  2. Offline

    Edward Hand

    If you use the yaml classes directly you can do just about anything.
    Code:
    Yaml yaml = new Yaml();
    Map<String,Object> map = (Map<String, Object>) yaml.load("plugins/directory/file.yml");
    That will create a hashmap with the keys "foo" and "bar" linked to further hashmaps (which in turn are <String,Object> maps) and so it keeps going until you finally get to values.
     
  3. Offline

    xZise

    Okay, but it is not possible to use the build in class Configuration of Bukkit?

    Fabian
     
  4. Offline

    phrstbrn

    I found this thread in a Google search. I hate finding threads that nobody replies with the answer, or "nvm I figured it out" without anybody posting the solution.

    Anyways, passing null to getKeys() seems to fix OP's problem

    Code:
    List<String> rootKeys = conf.getKeys(null);
     
  5. Offline

    xZise

    Yep, but this is the only method where null means the node itself. And by the way the “conf.getKeys()” does the same.

    Fabian
     
Thread Status:
Not open for further replies.

Share This Page