bukkits Configuration class: How to read an YAML associative array?

Discussion in 'Plugin Development' started by hmpf, Apr 7, 2011.

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

    hmpf

    Hi there,

    simple question: How do I read associative arrays from a yml file via the bukkit Configuration class?
    YAML documentation says these arrays are written like this:

    Code:
    Test:
      - Item0TestKey1: TestValue1
        Item0TestKey2: TestValue2
      - Item1TestKey1: TestValue1
        Item1TestKey2: TestValue2
    I tried working with getNode and getNodeList but hadn't had any luck getting the values I want.

    I tried this:

    Code:
    List<ConfigurationNode> nodeList = config.getNodeList("Test");
    Eclipse debug tells me that nodeList contains two items in elementData. Each Item is of type ConfigurationNode and contains the keys and values from above. Yay!

    However.. if I now use:
    Code:
    for( ConfigurationNode node : nodeList)
    {
      String test = node.getString("Item0TestKey1", "Nothing");
    }
    debug tells me that test has the value "Nothing" as in: I havent got anything from the node.

    Any help with this is appreciated!
     
Thread Status:
Not open for further replies.

Share This Page