How i add comments to the configuration file?

Discussion in 'Plugin Development' started by Gonmarte, Aug 31, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    Hi guys
    Hi would like to add some commends to my config file like

    #Message that appears when a player join server.
    message: This server is AWESOME!

    My config

    message: Ola comandante!
    The problem is that when i load the plugin in my server it creates the config file, but doesnt show that #Message just shows the message: Ola comandante!

    Can u help me?

    Thank you!
    Last edited: Aug 31, 2015
  2. Offline


    I Have the same problem... :p
  3. Offline


    The simple answer is, you can't.

    After using Plugin#saveDefaultConfig(), using Plugin#saveConfig() will remove all comments but the header. The FileConfiguration simply doesn't really allow comments. There are some libraries that you can download and use that allow you to make comments, but using Bukkit's stuff on its own is hard to achieve this.
  4. Offline


    @travja My comments save perfectly, what I use is this:

    Synapz likes this.
  5. Offline


    No thats wrong, you can Ive done it before same way @SuperSniper did on my WarningManager plugin
  6. Offline


    Are you making that message editable while in game? If not then you will never need to save the config, just make it so that in the onEnable it saves the default config if it doesn't exist (using Plugin#saveDefaultConfig()). Loaded Configurations do not save comments, that's kind of the point of them, so once you save that loaded config it'll remove where the comments used to be
    travja and Gonmarte like this.
Thread Status:
Not open for further replies.

Share This Page