Util Configuration with loading and saving comments.

Discussion in 'Resources' started by KingFaris11, Sep 26, 2015.

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

    KingFaris11

    Hey, I made a custom configuration class (extending YamlConfiguration) that loads/saves comments.

    It is no where near as efficient as I/you want it to be, and I know that I made it in an inefficient manner, but it's the only way I could think of making something like this. I've decided to share it here even if it is inefficient for anyone to use (and does not care too much about some inefficiency).

    I'd appreciate feedback on how to make this more efficient!

    Code: https://gist.github.com/KingFaris10/bea8b6cd701193290be7

    Note: I haven't gone through extensive testing with this so it may have a few bugs. If you find any bugs, please report them and/or find the solution and post it here, thanks!

    Example 1:
    I want to create a default config.yml like:
    Code:
    # Set this to 'true' if you want to allow players to drop items.
    Allow item dropping: false
    # Set this to 'true' if you want to allow players to pick up items.
    Allow item picking: false
    
    You would do something like:
    Code:
    File configFile = new File("config.yml");
    CustomConfiguration config = CustomConfiguration.loadConfiguration(configFile);
    config.addDefault("Allow item dropping", false, "Set this to 'true' if you want to allow players to drop items.");
    config.addDefault("Allow item picking", false, "Set this to 'true' if you want to allow players to pick up items.");
    try {
        config.save(configFile);
    } catch (Exception ignored) {
    }
    
     
    Last edited: Jan 2, 2016
    jyhsu and dvargas135 like this.
  2. Offline

    dvargas135

    Thanks!
     
  3. Offline

    KingFaris11

    No problem <3
     
  4. Offline

    zlToxicNetherlz

  5. Offline

    dvargas135

    Could you pls make an example for how to use it?
     
  6. Offline

    sachal2406

    Hi thanks for this but you could give more informations about it? For me it's still deleting comments and I don't really know how to use it :/
     
  7. Offline

    KingFaris11

    Will do after school.
     
Thread Status:
Not open for further replies.

Share This Page