0

Hey there,

I've got a small problem. I am creating a plugin for Bukkit. I tried to code a in-game config editor - that means that one can change configuration options with a command from inside the game. I already got it to work, but as of the build I'm using (#2879), the method YamlConfiguration.set(String, Object) doesn't seem to work. Here is the essential part of my code for setting and saving the YamlConfiguration I've got.

plugin.debug("option = "+option); // the configuration option
plugin.debug("newvalue = "+value); // the new value
config.set(option, value); // this should set the value of 'option' to 'value'
plugin.debug("savedvalue = "+config.get(option)); // the value saved in the config

As I tested my plugin, I've got the following output.

option = debug
newvalue = false
savedvalue = true

If you need the full and detailed code, look into it on GitHub: GeneralCommands.java, function config(CommandSender, String, String) (line 1074).

Kind regards.

mezzodrinker
  • 998
  • 10
  • 28
  • Making a debug method is smart. I don't know why I never thought to make one. – Kammeot Sep 21 '13 at 02:49
  • The method set() only works if the YamlConfiguration has the option already in it. I think you need to do addDefault(option, value) at least once before you can do set(option, value). I'm not exactly sure though, so try it and report back if it works. – Kammeot Sep 21 '13 at 02:55
  • @InspiredOne Hm, that might be a possibility. I'll try it. But I have to say that everytime before this error, I never ever used `addDefault()` before and it still worked (see [ConfigProperties.java](https://github.com/lirtistasya/RegionManager/blob/master/src/com/lirtistasya/bukkit/regionmanager/configuration/ConfigProperties.java)) – mezzodrinker Sep 21 '13 at 11:45
  • @InspiredOne Well, it didn't work out. I am not using a complete new `YamlConfiguration`, I get it via `plugin.getConfig()` (which I coded myself; see GitHub). – mezzodrinker Sep 21 '13 at 11:59
  • Oh, okay. It was not a problem with the `set()` method but with the `plugin.getConfig()` method. My bad. By the way, how can I tag a question as solved? – mezzodrinker Sep 21 '13 at 12:03

1 Answers1

0

My bad, it was a problem with another method I used (plugin.getConfig()).

mezzodrinker
  • 998
  • 10
  • 28