Config not loading.

Discussion in 'Plugin Development' started by Tehepicford, Aug 24, 2012.

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

    Tehepicford

    Help, Again. Configs arent loading.
    This time. No errors! But no config :(

    Code:
    package src.com.fordnatford.Commands.Main;
     
    import java.io.File;
    import java.io.IOException;
     
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
     
        @Override
        public void onEnable() {
            //PluginDescriptionFile pdfFile = getDescription();
            PluginManager pm = this.getServer().getPluginManager();
     
            if(!this.getDataFolder().exists()) {
                this.getDataFolder().mkdirs(); 
            }
            //file1 = new File(getDataFolder(), "Permissions.yml");
         
            try {
                getConfig().save(new File(this.getDataFolder().mkdirs() + "config.yml"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
     
        @Override
        public void onDisable() {
            System.out.println(this.toString() + " disabled");
        }
     
    }
     
  2. Offline

    sternmin8or

    getConfig().options().copyDefaults(true);
    saveDefaultConfig();
    Thats all you need, nothing else
     
  3. Offline

    Tehepicford

    I kinda want multiple configs.

    And also, Still no configs generating...
    Commands > config.yml

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  4. Offline

    skore87

    Because you aren't loading it.....


    Why?? You aren't giving it a custom name or location, so you don't need to use that method. Use saveConfig(). To reload a config is reloadConfig() though you aren't likely to use that. To get data from it, you use getConfig().getXXX("Path.To.Node") where the x's are multiple different get methods.

    And stop SPAM BUMPING your posts. No one will want to help you with that annoying behavior....

    And for more info on creating additional config files...
    http://wiki.bukkit.org/Introduction_to_the_New_Configuration
     
  5. Offline

    Tehepicford

    Code:
    package src.com.fordnatford.Commands.Main;
     
    import java.io.File;
    import java.io.IOException;
     
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
     
        @Override
        public void onEnable() {
            //PluginDescriptionFile pdfFile = getDescription();
            PluginManager pm = this.getServer().getPluginManager();
     
            getConfig().options().copyDefaults(true);
            saveDefaultConfig();
            try {
                getConfig().save(new File(this.getDataFolder().mkdirs() + "config.yml"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
     
        @Override
        public void onDisable() {
            System.out.println(this.toString() + " disabled");
        }
     
    }
    No folder, No nothing.
     
  6. Offline

    skore87

    Read my post again.
     
  7. Offline

    Tehepicford

    Shoot sorry, I did not read that very well...

    Code:
        @Override
        public void onEnable() {
            //PluginDescriptionFile pdfFile = getDescription();
            PluginManager pm = this.getServer().getPluginManager();
     
            getConfig().options().copyDefaults(true);
            saveDefaultConfig();
            saveConfig();
        }
    Does not work, Sorry if its just me being an idiot.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  8. Offline

    skore87

    You aren't ever writing to it either... And no need of saveDefaultConfig(). Read the link I posted.

    Edit: There's also one piece I think is missing or I overlooked at that link.

    Code:
    getConfig().addDefault("path", value);
    getConfig().options().copyDefaults(true);
    saveConfig();
     
  9. Offline

    Tehepicford

    OH MY GOD! I have been trying this for 2 days! And the most stupidest thing happened ever! I was editing the wrong one! And exporting the other!
     
Thread Status:
Not open for further replies.

Share This Page