Cleaning out config.

Discussion in 'Plugin Development' started by Worthless_Hobo, Oct 27, 2014.

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

    Worthless_Hobo

    So Im working on a plugin that currently saves player info to the config (Gonna change it to a custom YAML file later) and Im trying to figure out the best way to go through the config every time the plugin is enabled and delete the information from any player who hasn't played in the last month. I was wondering what people thought would be the best way of doing this.
     
  2. Offline

    ColonelHedgehog

    I think a good idea is to loop through the sections in the config, then match each one to an OfflinePlayer. If the difference of the server time to the OfflinePlayer's getLastPlayed() time is greater than 1000 x 60 x 60 x 24 x 30, set the path to "null."

    To loop through the config, I believe you can use this method (although I have not tried it myself):

    Code:
    for(String key : config.getConfigurationSection("Path.To.Section.With.Players").getKeys(false))
    {
    config.getString(key); // Do whatever
    }
    
     
  3. Offline

    Worthless_Hobo

    Alright Ill try that and see if it works, thanks.
     
Thread Status:
Not open for further replies.

Share This Page