Having trouble to check if Configuration-node exists

Discussion in 'Plugin Development' started by Pasukaru, Jun 7, 2011.

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


    Hi there...
    I couldn't find anything about this using the search, so I hope to find some answers here :D
    Im trying to check if a node of the Configuration file exists. (Im using bukkits "Configuration" class)
    Well, this is what I tried - but it always returns null:
    Configuration config = getMyConfig(); //(Im using a manager)
    ConfigurationNode node = config.getNode("this.is.my.node");
    boolean exists = ( node != null );
    System.out.println("Node exists:" + exists);
    I'm not sure if I use the getNode() method correctly here, but that might be the problem.

    I don't actually need to know if a node exists, but wanna improve my Plugin a bit, and this would help me a lot. :p

    Thanks in advance!

    I found a workaround:
    public boolean nodeExists(Configuration config, String nodePath){
        String node = config.getString(nodePath);
        return ( node != null );
    Not tested with lists though, but it works with primitive data types (int, boolean,...) and Strings as expected.
Thread Status:
Not open for further replies.

Share This Page