Ok so I wrote this little tiny tutorial on how create a config.yml using the new CB1317+ API Bare in mind this took about 2-3 mins and I wrote it in Notepadd++ and is mainly aimed at new developers starting out and wanting to get into the configuration side of plugins. Code: // decleare this in your mainclass at the top FileConfiguration config; // call this method in your onEnable() public void setupConfig() { config = this.getConfig(); // fill in these addDefaults with your config values config.addDefault("String value here" , "Default value"); config.addDefault(); config.addDefault(); config.addDefault(); config.addDefault(); config.options().copyDefaults(true); saveConfig(); } Please rate this tutorial using the poll thank you
For most plugins, defaults should NOT be instantiated in the code explicitly. The defaults should in put into a default yaml file and included in the jar, where plugin.yml is. JavaPlugin's getConfig method will load config.yml from your plugin's data folder and load defaults from the jar.
It should be even more simple, to put a default yaml with defaults in the same directory as plugin.yml
So how would you create a automatically generated config because this way works and I know it does so I dont see anything wrong yes there might be a different way please enlighten me.
When I do this it doesn't create a config file. How do i make it so it creates a file for the config?
I would also like to add that this method only works whilst using it within the main Class, you can retrieve this info from another class yes however if you try to create a reload command then you cannot use the variable "config" in your other classes you either have to make a new variable for that new class or just use getConfig()