[API] ConfigCreator 1.2

Creating more config files was never this easy before!

  1. RobiFoxx
    Tested Minecraft Versions:
    • 1.8
    • 1.9
    • 1.12
    Installation:
    1. Click on Download
    2. Create a Config.java file in your project
    3. Copy the contents from gist to your class
    4. Check the Usage for more informations.
    Download link leads you to a gist. Alternatively, you can click here.
    (https://gist.github.com/RobiFox/9101eecb34f4a5078342ec762d739898)

    Usage:
    • Open your project and create a new Config file in the Main class
    Code (Text):
    Config c = new Config("plugins/MyPlugin", "ExampleFile.yml", this);
    • Use the "create" method to create it.
    Code (Text):
    Config c = new Config("plugins/MyPlugin", "ExampleFile.yml", this);
    c.create();
    • Create a file just like making "config.yml", and write your default paths there.
    [​IMG]
    • Do an if statement for existence
    Code (Text):
    Config c = new Config("plugins/MyPlugin", "ExampleFile.yml", this);
    c.create();
    if(!c.exists()) { }
    • If not, set the file's default, copy them, and save it.
    Code (Text):
    Config c = new Config("plugins/MyPlugin", "ExampleFile.yml", this); // ExampleFile.yml is the output file
    c.create();
    if(!c.exists()) {
    c.setDefault("ExampleFile.yml"); // Your file name in your jar file
    c.getConfig().options.copyDefaults(true);
    c.saveConfig();
    }

    • Create a variable to make it available from other classes, and assign it, too.
    Code (Text):

    public Config example;
    public void onEnable() {
       Config c = new Config("plugins/MyPlugin", "ExampleFile.yml", this);
       c.create();
       if(!c.exists()) {
          c.setDefault("ExampleFile.yml");
          c.getConfig().options.copyDefaults(true);
          c.saveConfig();
        }
        example = c;
    }
    • You can convert it to a file by doing: Config.toFile();
    • You can convert it to YamlConfiguration by doing: Config.getConfig();

Recent Updates

  1. ConfigCreator [1.2]
  2. ConfigCreator [1.1]

Recent Reviews

  1. RAFAELESPADA
    RAFAELESPADA
    5/5,
    Version: 1.2
    Thanks for making this! Continue to do a great work :) You can reload and create configs very fast without adding any jars to your build path. Thanks for this
  2. FiXed
    FiXed
    3/5,
    Version: 1.1
    Kind of interesting but has a lot of redundant code and has some... interesting naming conventions. However the rest is pretty nice, you should add things like setting, and getting values as well so they don't have to do X#X#X and just do X#X.
    1. RobiFoxx
      Author's Response
      Thanks, and use c.getConfig().getString() (for example), if you mean that.
      But the code is open source, so you are free to modify it.
  3. --TOMAS--
    --TOMAS--
    5/5,
    Version: 1.1
    Nice api!! Really nice. But, you can tell me, how to reload config?? Thankssssssssssssssssssssssssssssssssssss

    Spigot 100 characters xD
    1. RobiFoxx
      Author's Response
      Thanks! :D
      also
      config.getConfig().reloadConfig(); (I believe)
  4. TreasureCakes
    TreasureCakes
    5/5,
    Version: 1.1
    Wow, thanks for this! It really helps, and makes it a lot faster to create config files for plugins!
    1. RobiFoxx
      Author's Response
      Thank you! :D