On restart, config does to default values

Discussion in 'Spigot Plugin Development' started by DecisionsYT, Jun 2, 2016.

  1. Hey!

    In my plugin, I have created a config file called "Toggles.yml"

    It has:

    Tab-Enabled: false at default. In game, when opening a GUI, you can set it to true or false. It all works perfectly fine and does what it's meant to, but on a restart/reload, it does to the default values (false) I need it to remember what the value was before a restart/reload
  2. The saveDefaultConfig() function will only save the default config if the config file does not already exist. If the config file exists and has been edited, it won't get reset back to default. That's just the way config files work.

    Are you saying you want to throw away any changes made to the config each time the server restarts?

    If so, you could do some IO to delete the config file and let saveDefaultConfig() regenerate the config file loaded with the defaults.
  3. I'm not talking about the config.yml by default, it's the Toggles.yml stuff that is what we're needing to be looking at.
  4. Ah ok, in that case I'm guessing the new values just aren't getting written to your Toggles.yml correctly. What's your code look like for this?
  5. The only things related to the file issues is above in my first post
  6. Are you even saving the file correctly?
  7. After setting the boolean for Tab-Enabled: true/false
    Code (Text):
  8. Does anyone have a fix to this?
  9. My suggestion is showing how you're creating, and saving your YAML file, usually this is the issue.
  10. My first post contains all code to do with it

    Sent from my iPod touch using Tapatalk