Solved Configuration with comments

Discussion in 'Plugin Development' started by KingFaris11, Jun 17, 2015.

Thread Status:
Not open for further replies.
  1. Yes, I know there have been many threads for something like this, but I just can't find one that matches my needs.

    Basically, I have this plugin, KingKits. It's highly customisable, so there's a lot of config options. The problem is, because there are so many config keys, it's very crammed up, and I have no comments to provide some information. This means people keep asking me questions about what something does in the config, or how to add stuff, etc.

    Currently, to setup my main config, I use addDefault (here) and then save the configuration. This obviously won't work with comments as saving the configuration removes all comments. I would like to use saveDefaultConfig(), but if I add a new config key, I'm not sure if it'll add it to everyone's configuration when they update the plugin?

    Also, I'd prefer a method that actually allows me to save the configuration WITH comments. This way, I can allow modification of the configuration within the plugin, for example, using commands.

    Does anyone know of a solution to my problem(s)? Thanks in advance.
     
  2. Offline

    Creeoer

    Have you tried compiling your plugin with the already loaded config.yml?
     
  3. If you're talking about with the "saveDefaultConfig" thing: I haven't even tried to use saveDefaultConfig() yet, so no, not really. But I think I looked into the SRC and all it does is copies the file if it is non-existent.

    If you're not: You probably misunderstood me. I know that the configuration loads with comments, but I want to make it so it can save the config (most likely not possible), and/or copy NEW default keys (so if I add new config options) to the current config that already exists.
     
  4. Offline

    Drkmaster83

    @timtower Er... sorry, you're the first moderator I was able to remember. Can we check out what's going on with saharmali? His post seemed unnecessary. Not sure whatup, is all. (Edit: Ah, he's also done the same thing on this post. Possible spammer? Either way, his images are kinda... disruptive of the topic. Just wanted to let you know.)
    EDIT by Timtower: fixed, please use the report button next time though.

    Moving on to you, @KingFaris11... my only suggestion, sadly, is to create some sort of algorithm with FileReaders and such. Check if a given line starts with a character that would be a comment for the given file type, skip that line if so. Then, just add all the found keys into an ArrayList and check it against a master copy. :\ Sorry if that doesn't make sense or even isn't possible.

    Kinda tired, but additionally, I've never done anything like this myself, either. Always just kinda dealt with the way the comments got removed. Created my own independent .txt files (that I would use JavaPlugin#saveResources(String name, ...can't remember what object) to create). Hope I gave you some ideas, man.
     
    Last edited by a moderator: Jun 18, 2015
    timtower likes this.
  5. 'aight yeah I get you. I kinda hoped that I wouldn't have to do this as it seems so complicated (to ensure Maps have indentations etc.) so I was wondering if one already existed before I even attempted at doing this, but anyway, thanks.
     
Thread Status:
Not open for further replies.

Share This Page