[Solved] How to find sub-paths of a path in config

Discussion in 'Spigot Plugin Development' started by Bolt, May 18, 2015.

  1. I was wondering if there was a way or some method to return a list of all the sub-paths of a particular path in a config.
    Code (Text):
    numbers:
      one: 1
      two: 2
      three: 3
    In a config such as the one shown above, how would I get a list containing "one", "two", and "three" as sub-paths of the path "numbers"?
     
  2. Code (Text):
    String one = getConfig().getString("numbers.one");
    String two = getConfig().getString("numbers.two");
    String three = getConfig().getString("numbers.three");
     
    Put these in the main frame of code do you can refer to these in any of your code.
     
  3. @Exus-Kun That was an example config file. I want a method that returns the sub-paths based on the config, not on set code such as yours because if the user were to change the config sub-paths to something else, I would then get errors. I want something that actually reads the path and returns the sub-paths.
     
    • Like Like x 1