How do I make it Create Configuration File

Discussion in 'Plugin Development' started by jay275475, Aug 21, 2013.

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


    Hello Bukkit Users I was wondering how do i make it generate a configuration file to edit the config
  2. Do something like this:

    1. File config = new File(this.getDataFolder(), "config.yml");
    2. if (!config.exists()) {
    3. this.saveDefaultConfig(); //Tests if config exists. If it does it saves it. If not, it proceeds with generating it
    4. }
    6. //Example
    7. getConfig().options().header("Plugin config file"); //Adds text to file. Will look like "# Plugin config file"
    8. getConfig().options().header("Modify the settings to your liking");
    9. getConfig().addDefault("Stuff", "some stuff here"); //Adds something to configure.
    10. getConfig().options().copyDefaults(true); //Copy defaults to file. Without this, the file will be blank
    11. getConfig().options().copyHeader(true);// same as previous
    12. saveConfig(); //Saves the file

    jay275475 Make sure all that is in your onEnable().

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page