[SOLVED] Another reloading issue ... wtf?

Discussion in 'Plugin Development' started by number1_Master, Jul 26, 2012.

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

    number1_Master

    I've reached another issue with reloading. This time, whenever I reload my config.yml via command, it resets whatever settings changed back default.
    Code:java
    1. //Code for reloading
    2. plugin.saveConfig();
    3. plugin.reloadConfig();
    4. sender.sendMessage(prefix + "Config reloaded!");
    5. return true;
    6.  
    7. //Code in onEnable to load the configurations
    8. public void onEnable()
    9. {
    10. FileConfiguration config = this.getConfig();
    11. //Configurations added here using config.addDefault("Whatever", whatever);
    12. getConfig().options().copyDefaults(true);
    13. saveConfig();
    14. }


    If you have the same issue has me, make sure you reload the config, then save it. DO NOT save the config before reloading it!
     
  2. Offline

    Sagacious_Zed Bukkit Docs

    Need more context.
     
  3. Offline

    number1_Master

    Like what? The command works (cause it displays the message I send). It worked before. There isn't anything to it.
    I'm testing it again.

    EDIT: Nope, issue continues.

    I did some research, and I found two forums with my exact same issue. The ways they solved the issue did not work for me. I find this unusual. Is it possibly a craftbukkit issue?
    http://forums.bukkit.org/threads/reload-line.82658/ (My exact issue)
    http://forums.bukkit.org/threads/changes-to-config-get-reset-on-reload.79314/ (Similar to my issue)

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

    russjr08

    Try flipping the reload and save on your reload method. I think you're saving the config that's in memory and then reloading that. Thus, loosing the changes.
     
  5. Offline

    Firefly

    Isn't because you copy defaults everytime your plugin enables, thus the defaults you have stored always overwrite your current config?
     
  6. Offline

    number1_Master

    I'm talking about reloading the plugin via command. I've used that method forever and it only copies the default keys.
    That is what I used to have, but then I figured: What is the point of saving after you reload? Shouldn't you save before you reload?
    I'll try flipping it. I'll get back to you with an answer!

    russjr08 Thank you of telling me to flip the reload and save. I had no clue that the save was screwing up the reloading.
    Thank you!

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

    russjr08

    No problem!! :D
     
    nunber1_Master likes this.
Thread Status:
Not open for further replies.

Share This Page