I'm just getting started with configs, and I'd like to know if it's better to use getConfig().getWhatever() each time I need to get a config value, or should I create a FileConfiguration variable? It would seem better to create a variable, but I looked at the source code of several plugins and they all use getConfig().getWhatever(). Also, if I was to use a config variable, I would have to reset it every time I ran the plugin's reload command.
Both options are the same. getConfig() points directly to the object. I would prefer using getConfig() because you got one variable less in your plugin then. For Spigot/Bukkit it doesn't matter which way you use.
Correct me if I'm wrong, but I don't think this is true. A variable is far more efficient because it reduces the number of instances of the config to just one - running getConfig() every time creates a new copy of the config each time, and can therefore reduce performance.
From the Bukkit source: public FileConfiguration getConfig() { if (this.newConfig == null) { reloadConfig(); } return this.newConfig; } Believe me, it doesnt create a new instance every time
The most simple method for him would actually be: Enable: (never overwrites itself once copied) Code (Text): public void onEnable() { saveDefaultConfig(); } and every time he/she needs to call upon it they can just use: Code (Text): this.getConfig().get<type>()
I use Code (Text): If (new File.getString().exists()) { reloadConfig(); } else { // Set config stuff here... }