Solved Adding entries to an existing config file

Discussion in 'Plugin Development' started by BladeFireTurtle, Apr 15, 2015.

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

    BladeFireTurtle

    Hello!

    I'm working on an update to an existing plugin of mine and what I'm wondering is whether you can add entries to an existing config file.

    I currently use the default config file that's included in my jar to set the config when it isn't found. What I would like to do it make it so that server owners updating to the latest version of my plugin don't have to wipe their config file as my plugin will just test for that entry missing and add it in if it is.
    I would still like to use the default config for all the other entries if possible.

    Clearly I haven't mucked around with the more manual way of doing configs so any help would be most appreciated!
    Thank you! :)
     
  2. Offline

    BladeFireTurtle

    @CodePlaysMinecraft Would that work though? There wouldn't be a path in the config to test for null in the previous versions of my plugin.
     
    Last edited: Apr 15, 2015
  3. Offline

    BladeFireTurtle

    @CodePlaysMinecraft Sure they could. However the way it is at the moment they would have to delete their config file or manually add the entry in for it to work, both of which are not desirable options.
     
  4. If so, you could set it in the config.
     
  5. Offline

    BladeFireTurtle

    I don't think you are quite understanding what I'm asking. The plugin wont be able to test for null on an entry that doesn't exist. I want my plugin to write the default entry, say:
    Code:
    keeplog:false
    if there isn't already that entry in the config. I don't want it however to change any other preexisting entries, simply add this one.
     
  6. Offline

    dart2112

    Code:
    if(!getConfig().contains("Path"){
    getConfig().set("Path","Stuffs");
    }
    Was done without IDE, just make sure that its all the right spelling before you go using it
     
    BladeFireTurtle likes this.
  7. Offline

    teej107

  8. Offline

    BladeFireTurtle

    Thank that's what I was looking for. I'll mark as solved. :)
     
Thread Status:
Not open for further replies.

Share This Page