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

    Gonmarte

    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

    Code:
    #Message
    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

    AL_1

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

    travja

    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

    SuperSniper

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

    Code:
            saveDefaultConfig();
            reloadConfig();
    
     
    Synapz likes this.
  5. Offline

    Synapz

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

    Xerox262

    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