Update config

Discussion in 'Plugin Development' started by kvq, Oct 11, 2015.

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

    kvq

    I often update config in plugin . How to save old values but add on server new lines from updated config .

    For example
    Config v1 (on server)
    Code:
    Object1: 10
    Config v2 (in plugin)
    Code:
    Object1: 15
    Object2: 30
    I want that when server administrator update plugin ,config for him should look so :
    Code:
    Object1: 10
    Object2: 30
    Really sry if i explaiend so bad
     
  2. Code:
    if (!config.contains("Object2")) {
    config.set("Object2", 30);
    saveConfig();
    }
    if you meant that.
    Or config.addDefault/config.setDefaults
     
    Zombie_Striker and kvq like this.
  3. Offline

    Scimiguy

    @kvq Or alternatively, save the values as a list.

    You can get the list, add the element, then save the list to config again
     
Thread Status:
Not open for further replies.

Share This Page