Solved the config.yml of my plugin keeps resetting

Discussion in 'Spigot Plugin Development' started by JJCDeveloper, May 29, 2017.

  1. Hello guys.i need instant help from you guys.My plugin has a config.yml which users can set custom items.
    Idk why but recently my plugin started to add default settings whenever the server reloads.
    You can add other settings but the default settings like the premade options cannot be removed.Is there a solution for stopping the config.yml of my plugin to reset to the first state?
  2. - Do you save the config.yml?
    - Do you re-create the config.yml with a reload?
  3. What do you mean by recreate
  4. I guess you use saveDefaultConfig() or somethig similar.(Edit: you do)

    Instead check if the file#exists() and if not do file#save()

    Edit: watch this video, explains something similar to what i said
  5. i did but it still doesnt work
  6. Hey whats up dude, your problem is here:
    Code (Java):
    public void onDisable() {
  "RedPVP SocialGui by JJC has been disabled");

        public void loadConfiguration() {
    Look Once you disable your plugin, you simply make it reload the Config which does the following:
    - It resets everything made in the config! (Recommended to be removed)
    - loadConfiguration() method is doing the following:
    Once the plugin starts it gets the Config -> then it copy the Default Options (Cool)
    Next, it saves the Default Config (Cool)
    The only problem I think is, you are resetting and saving the config, So remove reloadConfig();

    I'm recommending you to make your Main class a bit cleaner.
  7. Thankyou guys for helping.
    However i have figured out other ways to solve my problem.
    Thankyou so much for helping.