Solved Best way to reload config

Discussion in 'Spigot Plugin Development' started by Dramatically, Jan 16, 2020.

  1. To load the config I use saveDefaultConfig() but this is not reloading the config when I call it at the reload command. I’m not home to try other functions so can somebody try and help . I have not tried saveConfig() or reloadConfig() yet.
  2. Why are you asking how to reload the config if you already know about JavaPlugin#reloadConfig() which obviously does what you are asking for?

    The thing saveDefaultConfig() does is only saving the default config from your plugin jar to the plugins data folder.
  3. As you've said, using reloadConfig() is what you need.

    I personally create a custom method for reloading as I want various checks or need to reload other files at the same time as a normal config reload, but yes, you already have your answer.
  4. Would that fully reload the getConfig procedure with the saved edited config? It’s been some time since I’ve had a reload command.
  5. Yes, reloading the config, basicly updates it, so getConfig() gets the updated information from whatever was edited.
    • Winner Winner x 1
  6. Code (Java):
    This saves the config.yml from the jar to the data directory if it is missing, loads config.yml into getConfig() and sets your original config.yml as the default incase config.yml was edited and items removed.
    • Winner Winner x 1