Does copyDefaults() method copy values pre-written by config.yml in the IDE SRC ?

Discussion in 'Spigot Plugin Development' started by SkyAcer009, May 25, 2018.

  1. Using this:
    Code (Text):;
    Will save the config, but when I load my plugin, the config is null.

    Code (Text):

    plugin.saveResource("config.yml", false);
    But the above method shoots an error in the config when you attempt to reload the plugin (using PlugMan) and config does already exist.
  2. I think you want to be able to copy a config from your src to your plugins folder. If yes use:
    Code (Text):
  3. You can do it in two methods,

    1 :
    Code (Text):

           try {
           } catch (IOException e){
    2 :
    Code (Text):

    Bukkit.getPluginManager().getPlugin("YourPluginName").saveResource("config.yml", true);
  4. Choco


    Just call #saveDefaultConfig() in your onEnable() :p Come on, guys
    Code (Java):
    public void onEnable() {
    • Like Like x 3
  5. I'm not using the default spigot configuration.
  6. Just check the method bukkit uses. (Control and click on saveDefaultConfig(), i did that before and it worked)
  7. That doesn't save the default spigot config, it saves your default config (any file called config.txt in the src file)
  8. Choco


    Well given the information we have from you, it looks like that's what you're doing. "config.yml" is YOUR configuration file for YOUR plugin, saveable with #saveDefaultConfig(). If that's not what you want to do, let us know what you're trying to do. Calling #saveDefaultConfig() will take the config.yml from your project's root directory and save it to your plugin's data folder directory with all the default values in your source if it does not already exist. Based on the information given in this thread, that is what the you desire.
  9. Unfortunately, #saveDefaultConfig() does not save comments other than the topmost one. To save comments, you wil have to write your own method and copy the file that way.