Fabric API

Fabric API

106M Downloads

Adding Configuration API

darkerbit opened this issue ยท 1 comments

commented

I believe it is time to start work on a proper configuration API, rather than the two or three multiple formats in use today.

We have held multiple votes for what config format to use, and democracy has chosen JSON5.

The configuration API would add a config directory to .minecraft (or under mods, thoughts?), where each mod would have it's own directory with however many config files it wants.

It would, in the case that the target config file does not exist, use a default file from the mod resources' config folder, and copy it to the main config directory as well for editing.

Possible API example:

// Creates a loader that will load from config/modid/blocks.json5, and if it doesn't exist it will load it from the .jar resources at config/blocks.json5
FabricConfigLoader loader = new FabricConfigLoader(new Identifier("modid", "blocks"));

// Loading, GSON-like API
ModidConfigObject a = loader.load(ModidConfigObject.class); // Load the whole file
String b = loader.load(String.class, "object/string"); // Load a part of the object
Integer c = loader.load(Integer.class, "array[2]"); // Load another part, this time an array

With the following JSON5:

{
    object: {
        // This is a comment!
        string: "Hello, world!"
    },
    array: [0, 5, 3, 54]
}

Thoughts?

commented

Wrong repository, issue already exists in loader repo.