add key to config when a player updates plugin, where I want it to go.

Discussion in 'Plugin Development' started by Shzylo, Jul 28, 2013.

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

    Shzylo

    I have seen so many of these posts before, but somehow I cannot find any posts on it, I believe I am doing an incorrect search and cannot find them.

    A new version of my plugin will contain a new key it needs to get, and I don't know how to get the key to write to the file, and how to get it where I want it to go, or how to delete the old config and create it with the new update.
     
  2. Offline

    CubieX

    Adding a key:
    Code:
    getConfig().set("my.New.Key", value)
    You can't control where it will be. It will be added to the end of the file.

    If you want to update the whole config
    (which is a bad idea in my opinion... the user should not loose the old config without knowing it. Because he customized it earlier.),
    you would have to delete the file and create a new default config, like it was the first start aft installation of the plugin.

    Removing all keys manually would also work. But perharps there are updated comments in the header of the file.
    So I guess deleting and creating it from your default config will be more practical, if you really need to do this.
     
Thread Status:
Not open for further replies.

Share This Page