Save comments in config.yml with api spigot/bukkit

bukkit config
how to edit spigot config
bukkit custom config
spigot using config file
spigot config class
spigot read from config file
custom yml spigot
spigot add to config

I have a config.yml file that has some comments like:

#Thats the message when someone joins to the server
Message: Hello User

But when I save the config.yml file and open again it vanishes and can't be saved I tried to search some api for this problem but could not find I dont want to use

saveDefaultConfig();

or

getConfig().options.copydefault(true);
saveConfig();

Because I dont want to save this threw code I want to save this with api. What api should I use

I would recommend you to use the Spigot API, on my opinion it's the better one

Both API's only support ONE comment in the header section of the config. If you want to save more than one comment you should code your own YAMLConfiguration

To save this one header you should try

getConfig().options().header("Your Comment");
getConfig().options().copyHeader(true)

You can seperate the comment with \n into mutliple lines

[HELP] how to add comments to the config, You can't add comments via Bukkit's configuration API. which will save the resource called custom.yml with the comments, though writing  only problem with reading the config.yml from inside the plugin and storing it that on first try the comments are there afterwards they are gone.. you need to have a custom config API to save comments again and again either by using something like sync, my helperclasses (in the future) or by writing your own.

You can create a config.yml inside your src folder which will be included into the jar. You can set your default values and any comments by editing this file in your IDE. All you have to do in your main class is calling saveDefaultConfig(); in your onEnable(). After that, you can use getConfig() to access your configuration.

Edit Config, Save Comments?, yml. Using the Bukkit Configuration API, the only way to get comments is through the header. Read up on this article, it explains what you are  A default config.yml should be provided in your jar for users. In the case that a config.yml is missing or incomplete, values will be loaded from included config.yml. The provided file must be named config.yml and be placed in the same directory as your plugin.yml. The file should have the intended structure of your config.yml. This file can be

Thats sadly not possible when using the given Tools!

You need to manually write your own ConfigManager where you can do that!

Here is what I got: https://mega.nz/#!lsIkVYhD!knZr5DBmbvPyJh8ONeNx4pfb7Q0C9yuIp6FHiyJmhBw

It may however have a few bugs :D

Configuration API Reference, The Configuration API can be found in the org.bukkit.configuration and Header is the comment block at the top of a YAML file, it is applied to the save output. Bukkit config.yml connection. 1. Bukkit plugin get locations from config.yml. 1. Save comments in config.yml with api spigot/bukkit. Hot Network Questions

Building Minecraft Server Modifications, Writing a config.yml file Now, it is time to start writing the config.yml file. Note the comments in the example indicated by the # character. few mobs are included in this config file, but the names of all the mob types can be found in the API class at https://hub.spigotmc.org/javadocs/spigot/org/ bukkit/entity/​EntityType.html. The plugin (actually Spigot to be precise, because the Shopkeepers plugin uses a piece of Spigot API to store and load the items inside the save.yml file) storing the color codes with '&' instead of '§' is normal and intended. The color codes get converted back to § again when these items are loaded from the save.yml file.

Writing a config.yml file, Tip. Only a few mobs are included in this config file, but the names of all the mob types can be found in the API documentation  I was experimenting with the Spiget API (and downloading spigot plugins in general) and came up with an idea to make a package manager to install plugins for your minecraft server. This is a CLI application made in JS, also as kind of an experiment.

Java Code Examples org.bukkit.configuration.file.YamlConfiguration, This page provides Java code examples for org.bukkit.configuration.file. public boolean save(){ YamlConfiguration recipe; File f=new File(rs. loadConfiguration(yml)); FileConfiguration config = api. public Config(​InputStream configStream, File configFile, int comments, JavaPlugin plugin) { this​.comments = comments; 

Comments
  • I'm not sure, but I believe that only the comments on the first line will be removed. Could you verify that?
  • I tried and All the comments are removed when I press save
  • The problem is that it doesn't save the comments after i save the file not run the plugin
  • As I said in the post I dont want to use that command because it wont work