Solved Some sort of Config problem

Discussion in 'Spigot Plugin Development' started by GamerAPI, Mar 17, 2020.

  1. I have a yml config, and I'm not exactly sure how to do what I want to do. My code looks a bit like this:
    Code (Java):
            if (!config.isSet("node"))
            for (String s : config.getStringList("node")) {
                String set = "node." + s;
                World world = Bukkit.getWorld(config.getString(set + ".world"));
                double x = config.getDouble(set + ".x");
                double y = config.getDouble(set + ".y");
                double z = config.getDouble(set + ".z");
                System.out.println("World: " + world.getName() + " X: " + x + " Y: " + y + " Z: " + z);
    And the config (Already set) looks like this:
    Code (YAML):
    : world
    : -32.955715702069114
    : 69.0
    : 277.5710302641944
    I'm not sure exactly what I'm doing wrong, what I am trying to do is get a list of locations from a config from a certain name. It doesn't throw any errors in the console, and I'm not sure what I am doing wrong.
  2. "node" is not a StringList, what you need to do it get all the sections within the ConfigurationSection "node". To loop through all the sections you can call <ConfigurationSection>#getKeys(false)
    In your case that would return "test" then you can do whatever you need from there.

    Code (Text):
    for(String s : config#getConfigurationSection("Spigot").getKeys(false)) {
      if(config#getString("Spigot." + s + ".Name")#equals("Bobcatsss")) {
  3. Thank you man, very helpful.
    • Friendly Friendly x 1