Carleslc / Simple-YAML

This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
https://carleslc.me/Simple-YAML
GNU General Public License v3.0
130 stars 38 forks source link

The method for saving the config is not working. #73

Closed thelipe7 closed 1 year ago

thelipe7 commented 1 year ago

Hello, I am trying to set values after loading a config but the new values are not being set, my code: image image No exception is thrown, the file seems to be modified as the date changes, but the configuration values do not.

Carleslc commented 1 year ago

How do you load/create your config file? And what getConfig() returns? An instance of YamlFile? Also you do not need to load the file again after saving. Use get("parkour.start-location") to see if the value has changed after set (or getString if location is a string). Loading values are only needed the first time, when the plugin starts, and optionally on plugin reload.

Carleslc commented 1 year ago

I'm closing this issue since there are no further details to help you and I think is not an issue with this library.

I'm guessing you have two different configuration instances and you are confused setting values on one and saving another configuration without those values set. Ensure getConfig() returns the same yamlFile instance as in your save / reload methods, and that those methods are actually executed, and getConfiguration() does not return another different configuration instance instead.

LobbyPlugin.getInstance().getConfig() == LobbyPlugin.getInstance().getConfiguration().yamlFile should return true (same instance).

Otherwise, maybe you are confusing the Bukkit's plugin configuration with the configuration instance of this library (YamlFile)? Please don't mix them, use one or another. This library is independent of Bukkit / Spigot / Velocity and can also be used in any Java program.

You can comment if you need more help.