Config creator API!

Hey all I’ve been preparing my plugin for when the implementation comes out and for that I had to make a config system. So I made this and tought maybe others want it too?
So it works really simple you make an Config object.
In this you can add settings or load an old config file and read out settings from there! example:

Config config = new Config(“config file name.txt”);
config.add(“TeleportCost”,93);
config.add(“OPcanTpOthers” , true);
config.creatConfig();

so for the second time you can do something like:

config.loadConfig();
config.read(“OPcanTpOthers”);
config.add(“PlayersThatLikeSponge”,9001)
config.read(“PlayersThatLikeSponge”)

Ofcourse all of this will be neatly saved in the filename.txt in your plugin folder which can also be edited from a normal text editor.
So would you guys like me to make an API for this ? feedback is welcome :smiley:
~thimovss

Why don’t you use the HOCON formatted configuration that is provided directly by Sponge (see here) and is provided by each Sponge implementation? Unfortunately there is not yet a documentation beyond java docs on how to use these feature, but I am sure @Inscrutable and his team are working on it.

Even if you cannot use Sponge for configuration because you want to have the same configuration file on different plattforms (e.g. Bukkit, Sponge, MojangAPI…) there are better and fully matured alternatives compared to rolling out your own solution: Java’s Properties standard, maybe together with an external library such as Owner that takes care of most of the typical boilerplate code and reduce creating a Properties to this:

public interface ServerConfig extends Config {
    @Key("server.http.port")
    int port();

    @Key("server.host.name")
    String hostname();

    @Key("server.max.threads");
    @DefaultValue("42")
    int maxThreads();
}

Of the record, it would have been quit cool if Sponge’s config implementation worked a bit like Owner.

1 Like

@TheE didn’t even know that existed! thank you.