Solved Config help? [Need Help]

Discussion in 'Plugin Development' started by Josh014, Feb 7, 2014.

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

    Josh014

    Hey,
    If I want to change something in my config and I reload my server the config won't update.
    I can't find the problem in the code... (There are no errors or something related)

    Code:
    Code:java
    1. public void onEnable() {
    2.  
    3. PluginDescriptionFile pdfFile = this.getDescription();
    4. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion()
    5. + " Has Been Enabled");
    6. PluginManager pm = this.getServer().getPluginManager();
    7. getServer().getPluginManager().registerEvents(this, this);
    8. final FileConfiguration config = this.getConfig();
    9.  
    10. config.addDefault("KitPvP.KitsList", Arrays.asList(kits));
    11.  
    12. config.addDefault("KitPvP.KitStats.Standard.Enabled", false);
    13. config.addDefault("KitPvP.KitStats.Archer.Enabled", false);
    14. config.addDefault("KitPvP.KitStats.Pro.Enabled", false);
    15.  
    16. config.addDefault("KitPvP.KitStats.Standard.File", "KitStandard");
    17. config.addDefault("KitPvP.KitStats.Archer.File", "KitArcher");
    18. config.addDefault("KitPvP.KitStats.Pro.File", "KitPro");
    19.  
    20. config.options().copyDefaults(true);
    21. saveConfig();
    22.  
    23. pm.registerEvents(new KitPvP(this), this);
    24. getCommand("kitpvp").setExecutor(new KitPvP(this));
    25. getCommand("kp").setExecutor(new KitPvP(this));
    26. KitPvP.plugin = this;
    27. pm.registerEvents(new Effects(this), this);
    28. Effects.plugin = this;
    29. pm.registerEvents(new Inventory(this), this);
    30. Inventory.plugin = this;
    31.  
    32. }


    Thank you,
     
  2. Offline

    Josh014

    Code update (Still doesn't update when I manually update the config and then reload the server. It works fine with commands in game.):

    Code:java
    1. public void onEnable() {
    2.  
    3. PluginDescriptionFile pdfFile = this.getDescription();
    4. this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion()
    5. + " Has Been Enabled");
    6. PluginManager pm = this.getServer().getPluginManager();
    7. final FileConfiguration config = this.getConfig();
    8.  
    9. config.addDefault("KitPvP.KitsList", Arrays.asList(kits));
    10. config.addDefault("KitPvP.Soup", false);
    11.  
    12. @SuppressWarnings("unchecked")
    13. List<String> list = (List<String>) plugin.getConfig().getList(
    14. "KitPvP.KitsList");
    15. for (String k : list) {
    16. config.addDefault("KitPvP.KitStats." + k + ".Enabled", false);
    17. config.addDefault("KitPvP.KitStats." + k + ".File", "Kit" + k);
    18. }
    19.  
    20. config.options().copyDefaults(true);
    21. saveConfig();
    22.  
    23. getServer().getPluginManager().registerEvents(this, this);
    24.  
    25. pm.registerEvents(new KitPvP(this), this);
    26. getCommand("kitpvp").setExecutor(new KitPvP(this));
    27. getCommand("kp").setExecutor(new KitPvP(this));
    28. KitPvP.plugin = this;
    29. pm.registerEvents(new Effects(this), this);
    30. Effects.plugin = this;
    31. pm.registerEvents(new Inventory(this), this);
    32. Inventory.plugin = this;
    33. pm.registerEvents(new soupListener(this), this);
    34. soupListener.plugin = this;
    35.  
    36. }
     
  3. Offline

    L33m4n123

    do you save the config in your onDisable? that should to the trick
     
  4. Offline

    Josh014

    L33m4n123
    Yes this is my on disable:

    Code:
    Code:java
    1. public void onDisable() {
    2.  
    3. PluginDescriptionFile pdfFile = this.getDescription();
    4. this.logger.info(pdfFile.getName() + " Has Been Disabled");
    5. saveConfig();
    6.  
    7. }


    Fixed it! I just added: reloadConfig(); in the onDisable() {}

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

Share This Page