Auto creation of Yaml Configurations Options on Update

Discussion in 'Plugin Development' started by CRAZYxMUNK3Y, Apr 8, 2012.

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

    CRAZYxMUNK3Y

    Is it possible to create an extra option in a config file on reload/restart of server once a option has been added, for example;

    (Default Config)
    Code:
    worlds:
        - world
     
    world:
        -44
        -12
    
    (Edited During Server Up)
    Code:
    worlds:
        - world
        - world2
     
    world:
        -44
        -12
    
    (After reload/restart)
    Code:
    worlds:
        - world
        - world2
     
    world:
        -44
        -12
     
    world2:
        -<Other ID's>
    
    I hope this makes sense.

    Thanks
     
  2. Offline

    Lolmewn

    Sure is. Grab the list of Strings, check if they exist (.contains(string)), and if they don't, add it (I think it was .addDefaults and after that .saveDefaults()
     
  3. Offline

    CRAZYxMUNK3Y

    Thanks for the reply, all i have so far is this though :(
    Code:java
    1.  
    2. public static void checkWorlds(){
    3. if(!config.getList("Worlds").contains(worlds)){ //worlds = Array in main
    4.  


    Mind giving me a quick code for it?

    Thanks
     
Thread Status:
Not open for further replies.

Share This Page