-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
1.20.4
-
Yes
config.addComments doesn't work on added defaults. config.addComments only works on values that are already in the config.yml file or set values.
Relevant spigot forum post (by me)
The main method
@Override public void onEnable() { saveDefaultConfig(); FileConfiguration configuration = getConfig(); configuration.addDefault("test.bar", "foo"); configuration.set("test.asd", "dsa"); configuration.options().copyDefaults(true); configuration.setComments("test.bar", Collections.singletonList("this is the default set in the code")); configuration.setComments("test.foo", Collections.singletonList("this is the default set in the config.yml")); configuration.setComments("test.asd", Collections.singletonList("this is a set value using code")); saveConfig(); Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Plugin has finished."); }
The config.yml in the resource folder
test: foo: "bar"
The config generated by the plugin on the first time it loaded
test: bar: foo # this is the default set in the config.yml foo: bar # this is a set value using code asd: dsa
The config generated by the plugin after a server restart
test: # this is the default set in the code bar: foo # this is the default set in the config.yml foo: bar # this is a set value using code asd: dsa