adding comments to config in code

Discussion in 'Plugin Development' started by German121314, Aug 8, 2013.

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

    German121314

    Hi! I need a little help!

    I have the next code:
    Code:java
    1. config.addDefault("EXP_BOTTLE(S)", true);
    2. config.addDefault("LEATHER(S)", true);


    And this looks like:

    EXP_BOTTLE(S): true
    LEATHER(S): true

    But i want:

    ##Use only true or false
    EXP_BOTTLE(S): true
    LEATHER(S): true
     
  2. Offline

    lycano

    I suggest using github wiki pages to explain what to do here as i dont think that bukkit YAMLConfiguration supports adding comments before a node as its more oriented to store and load different types of values like string, boolean.

    If you still want to do this you would have to write your own FileConfiguration and add comments on save that will get their strings from a method like ...

    setBoolean(boolean value, boolean default, String comment)

    If comment has a value it would then add the comment before it.

    But this would also make it harder to get values. Also note that SnakeYML ignores comments completely which can result into losing all comments whenever the whole file is saved (just a guess).
     
  3. Offline

    German121314

Thread Status:
Not open for further replies.

Share This Page