Solved reloadConfig() isn't... working.

Discussion in 'Plugin Development' started by HeadGam3z, Jul 4, 2014.

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

    HeadGam3z

    So, I know reloadConfig() technically "discards any data in getConfig() and reloads from disk". But usually I can use this method for reloading my config.yml file that I applied changes to without any problem; not today though, for some reason.

    I am trying to reload my configuration file upon command with the reloadConfig method basically.

    This is what happens:
    1. I change my config.yml file.
    2. I save it.
    3. I go in-game and type /ereload.
    4. A message is sent to me saying the configuration is reloaded.
    5. But the config is the same as it was in-game, until I use /reload or restart the server.

    I've never had this problem before. In fact, I use this all the time. :c

    Reload Command
    Code:java
    1. Util u = new Util();
    2.  
    3. public boolean onCommand(CommandSender cs, Command c, String s, String[] a) {
    4. if (c.getName().equalsIgnoreCase("ereload")) {
    5. if (cs.hasPermission("test.ereload")) {
    6. cs.sendMessage(u.getReloadSuccess());
    7. Main.plugin.reloadConfig();
    8. return true;
    9. } else {
    10. cs.sendMessage(u.getNoPermissionCmd());
    11. return true;
    12. }
    13. }
    14. return false;
    15. }


    Main class, onEnable
    Code:java
    1. public static Plugin plugin;
    2. Handler h = new Handler();
    3.  
    4. public void onEnable() {
    5. plugin = this;
    6. h.addDefaults();
    7. getCommand("etest").setExecutor(new ETestClass());
    8. getCommand("ereload").setExecutor(new EReloadClass());
    9. }


    Handler class, addDefaults
    Code:java
    1. public void addDefaults() {
    2. FileConfiguration c = Main.plugin.getConfig();
    3. c.addDefault("Settings.TestMsgOne", "Test One");
    4. c.addDefault("Settings.TestMsgTwo", "Test Two");
    5. c.addDefault("Settings.TestMsgThree", "Test Three");
    6. c.options().copyDefaults(true);
    7. Main.plugin.saveConfig();
    8. }


    So, like I said, if I change TestMsgOne in my config.yml file to "Testing Testing 123", save it, then use the ereload command... I get the message saying it reloaded, but it doesn't take affect until I restart/reload the server - I know this because /etest sends the string of Settings.TestMsgOne.
    I've always reloaded my config.yml files like this. D:

    Any help would be great. thanks :D
     
  2. Offline

    Onlineids

  3. Offline

    HeadGam3z

    Onlineids
    Nope, still doesn't apply the changes. Thanks, though. :/

    Actually, I got it to work. There was a problem in my Util class I didn't realize until this morning. :)

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

Share This Page