TheElectronWill / night-config

Powerful java configuration library for toml, yaml, hocon, json and in-memory configurations. Serialization/deserialization framework.
GNU Lesser General Public License v3.0
242 stars 28 forks source link

Remove dont work #155

Closed Euphillya closed 9 months ago

Euphillya commented 9 months ago

Hello, I don't know why this is happening to me but remove() doesn't work, it doesn't remove the configuration, is this normal?

My code : https://github.com/Euphillya/Skyllia/blob/2129469c24486233f1b51dd2d613aa9992bd589d/plugin/src/main/java/fr/euphyllia/skyllia/configuration/ConfigToml.java#L82

TheElectronWill commented 9 months ago

Hello!

remove deletes an entry from the config, for example if the config is (toml syntax for the example):

a = "aa"
b = "bb"

you can config.remove("a") and only b will remain in your config (Well, in the in-memory version of the config, the file is unchanged until you config.save() or writer.write(config, ...), unless you enabled autosave ^^).

Can you show me how you call remove (your function)? What do you expect it to do?

Euphillya commented 9 months ago

https://github.com/Euphillya/Skyllia/blob/2129469c24486233f1b51dd2d613aa9992bd589d/plugin/src/main/java/fr/euphyllia/skyllia/configuration/ConfigToml.java#L191

Autosave is used :

https://github.com/Euphillya/Skyllia/blob/2129469c24486233f1b51dd2d613aa9992bd589d/plugin/src/main/java/fr/euphyllia/skyllia/configuration/ConfigToml.java#L45

TheElectronWill commented 9 months ago

Hmm 🤔 Okay, maybe something else is overwriting the removed value? Or maybe it's the wrong path? You're not using the config from multiple threads, are you?

It's probably not a bug in config.remove itself, but I'm sure you'll figure it out after some more debugging :)

Euphillya commented 9 months ago

It's okay, I understand the problem... I just wasn't doing the right version check. My apologies.

TheElectronWill commented 9 months ago

No worries, have fun programming!