Hi I have made a config.yml file and I have called it. The problem it I have set it up to have comments in it however when I load the server, go into my plugins file, open it the comments aren't there. Any ideas why? The top bit is the only comments working
@Vidsify Well the most likely reason that that may be the case, is that you are not saving your config on start up and reload. Try adding this into you onEnable() and onDisable() Code: this.saveDefaultConfig(); I almost forgot, this will not work if you just plonk it into your code and then run it. You will also have to delete your other config, the one in the plugins folder of your server. After that though, you should not need to delete it again.
@bwfcwalshy I king if figured that, just about to change it. I grabbed it from a plugin where I was experimenting with the config, and did not remove them. Oops.
@Gamesareme You also don't need to save the default config when you disable the plugin....that doesn't make much sense. @Vidsify It is because SnakeYAML doesn't preserve comments that aren't at the top of a file, if you want to save comments to a file, copy the file into the directory yourself and then don't write to the config.
@bwfcwalshy @mythbusterma My OnEnable Code Code: public FileConfiguration config; public void onEnable() { PluginDescriptionFile pdffile = getDescription(); this.log.info("[" + pdffile.getName() + "] v" + pdffile.getVersion() + " has been enabled!"); this.log.info("[" + pdffile.getName() + "] by Vidsify"); getServer().getPluginManager().registerEvents(this, this); loadConfiguration(); //AutoUpdater if (getConfig().getBoolean("AutoUpdate", true)) { Updater localUpdater = new Updater(this, 80039, getFile(), Updater.UpdateType.DEFAULT, true); } else { getLogger().info("NOT AUTO-UPDATING"); } //Load Vault setupPermissions(); setupEconomy(); setupChat(); getLogger().info("Linked to Vault!"); }
@Vidsify All you need to put there is saveDefaultConfig(), unless you're trying to copy comments, in which case copy the file from the .jar.
@mythbusterma I have set up the comments in my config.yml so do I just add saveDefaultConfig() to my onEnable()
@Vidsify I said, "if you don't want to copy comments, use saveDefaultConfig(), if you do, copy the file yourself."