Util ConfigurationUtil - Per option/section headers

Discussion in 'Resources' started by lenis0012, Mar 1, 2016.

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

    lenis0012

    I wrote a quick class that can load and save headers for any option or section in your bukkit config.
    Code:
    settings:
      # Economy settings are in dollars.
      # Enable to hook with vault
      economy:
        enabled: false
        currency: dollars
      # A value that decides how old you are
      x: 15
      y: 33
      z: 12
    It can load a config file and obtain its per-option headers, as well as being able to save it.
    this way you can have more detailed config files without having to replace them every time the original version changes.
    Source code of Configuration.java

    Loading the config
    Code:java
    1. File file = new File(getDataFolder(), "config.yml");
    2. Configuration config = new Configuration(file);
    3. config.reload(); // Load settings from file


    Applying headers
    Code:java
    1. config.header("settings.economy",
    2. "Economy settings are in dollars",
    3. "Donald trump is rich");
    4.  
    5. List<String> economyHeader = config.header("settings.economy");


    Saving the config
    Code:java
    1. config.save();
     
    Last edited: Mar 1, 2016
    jyhsu, jusjus112 and ChipDev like this.
Thread Status:
Not open for further replies.

Share This Page