Solved No need to delete config

Discussion in 'Plugin Development' started by Googlelover1234, Oct 7, 2014.

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

    Googlelover1234

    I've been working on a plugin, and it comes with a config, all fine and dandy. I've been recently doing some more updates, which require more editable things such as messages. I wanted to make it so if you have a newer version, instead of having to completely remove the current config, which has the already configured messages, it would just add it automatically. I am not sure how to do this, and I probably am missing something dumb. Any help would be fantastic :)
     
  2. Offline

    DotDash

    1. Check plugin version
    2. For every version higher than x, add config options with .set(String s, Object o)
     
    Googlelover1234 likes this.
  3. Offline

    Googlelover1234

    DotDash

    I thought of something like that, but I do have one question, why should I check the plugin version? Just to be safe?
     
  4. Offline

    DotDash

    Googlelover1234 Well how else are you supposed to see if the plugin has been updated?
     
    Googlelover1234 likes this.
  5. Offline

    Googlelover1234

    DotDash

    Okay, well anyway, so far I've gotten this:

    Code:java
    1. public void onEnable() {
    2.  
    3. registerCommands();
    4. registerEvents(this, new JoinEvent(this), new QuitEvent(this),
    5. new ChatEvent(this), new MoveEvent(this));
    6. if (!this.getDataFolder().exists()) {
    7. this.getDataFolder().mkdir();
    8. }
    9. this.getConfig().options().copyDefaults(true);
    10. this.saveConfig();
    11.  
    12. if (!this.getConfig().contains("Settings.admin-enable")) {
    13. this.getConfig().set("Settings.admin-enable",
    14. "&dYou are now in ADMIN mode");
    15. }
    16.  
    17. if (!this.getConfig().contains("Settings.admin-disable")) {
    18. this.getConfig().set("Settings.admin-disable",
    19. "&aYou are now in PLAY mode");
    20. }
    21.  
    22. }


    Which seems to work fine, thanks for your help! :D +1
     
Thread Status:
Not open for further replies.

Share This Page