saveDefaultConfig(); no longer saving correctly

Discussion in 'Plugin Development' started by Condolent, Jan 1, 2016.

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

    Condolent

    Read something about how saveDefaultConfig(); no longer saves the config. How do I solve this??
    I have in a 'Events' class a string list that saves a new players' UUID to set the player as registered. But I don't want the notes to disappear when it saves so saveConfig(); won't work.

    This is my initial config-code:
    Code:
    getConfig().options().copyDefaults();
    saveDefaultConfig();
     
  2. Offline

    Xerox262

    @Condolent There's nothing wrong with saveDefaultConfig(); You do not need to do getConfig().options().copyDefaults();

    saveDefaultConfig() does not save updates, you need to use saveConfig();

    If you're afraid that notes will be deleted then just create a second storage file with no notes in it.
     
  3. Offline

    Condolent

    @Xerox262 there's also a command that changes a boolean in the config so I need to fix this somehow
     
  4. Offline

    Xerox262

    Config files don't load the comments, so either you have to create you own configuration system or you can just store the changeable things in a separate file.
     
  5. Offline

    Condolent

    @Xerox262 that's not really true. I know it's possible and read a documentation that they changed the saveDefaultConfig a while back. Just forgot how to use it correctly.
     
  6. Offline

    Chloe-chan

    saveDefaultConfig() basically copy the config.yml in your SRC folder to the plugin's data folder if it did not exist.
     
  7. Offline

    Xerox262

    @Condolent Exactly, that's why they copy the comments, because they don't actually load the file, they don't even care what kind of file it is, they just write all it's data to the file.

    http://wiki.bukkit.org/Configuration_API_Reference
     
Thread Status:
Not open for further replies.

Share This Page