Plugin Help Detect child objects in YAML

Discussion in 'Plugin Help/Development/Requests' started by meowxiik, Oct 14, 2014.

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

    meowxiik

    Hello,
    Here is some quick one, I have YAML with this:

    Code:
    +A
      +A1
      +A2
      +A3
    +B
      +B1
    Is here a way to detect ALL children of something?
    Something like conf.getChild(A)?
    (It could return string datatype of the children?)
     
  2. Offline

    nlthijs48

    meowxiik As far as I know the specified example is not in a correct YAML format, but still I may be able to help you. You first need to get the ConfigurationSection of the part you want all keys from, and then you can use the getKeys() method:
    Code:java
    1. ConfigurationSection section = config.getConfigurationSection("path.to.section");
    2. section.getKeys(false); // returns only top-level keys
    3. section.getKeys(true); // returns all keys

    getKeys(false) would return +A and +B if called on the config itself, getKeys(true) would return a list of all of them.
     
  3. Offline

    meowxiik

    Thanks a lot!!
     
Thread Status:
Not open for further replies.

Share This Page