Mods
Resource Packs
Data Packs
Modpacks
Shaders
Plugins
Mods Resource Packs Data Packs Plugins Shaders Modpacks
Get Modrinth App Upgrade to Modrinth+
Sign in
ModsPluginsData PacksShadersResource PacksModpacks
Sign in
Settings
Prism Config

Prism Config

A lightweight config library for Java to let you write your config elegantly and flexibly. Theoretically standalone from any loaders.

388
6
Library

Compatibility

Minecraft: Java Edition

1.19–1.19.3
1.18.x
1.17.x
1.16.x
1.15.x
1.14.x

Platforms

Fabric
Quilt

Supported environments

Client-side
Server-side
Client and server

90% of ad revenue goes to creators

Support creators and Modrinth ad-free with Modrinth+

Links

Report issues View source Join Discord server

Creators

Flamarine
Flamarine Owner

Details

Licensed MIT
Published 2 years ago
Updated 2 years ago
DescriptionChangelogVersions
Icon

java8 gradle Release

A lightweight config library for Java to let you write your config elegantly and flexibly.

Getting Started

For users, Prism Config can be installed as a Fabric mod natively as it includes a fabric.mod.json, but it is mostly for JiJ, and the mod itself is actually just a normal Java library, so it can theoretically run on any Minecraft version with any loader. However, support for specific mods, like Mod Menu, is planned.

For developers, to add Prism Config to your project, you need to add following into your build.gradle(.kts):

Groovy DSL:

repositories {
    // ...
    maven {
        name = "Nova Committee - Release"
        url = "https://maven.nova-committee.cn/releases/"
    }
    maven {
        name = "Nova Committee - Snapshot"
        url = "https://maven.nova-committee.cn/snapshots/"
    }
}

dependencies {
    // ...
    implementation "io.github.prismwork:prismconfig:0.2.0:all"
    // Or use the slim jar if you have the libraries included in your project (Gson, Jankson...)
    // implementation "io.github.prismwork:prismconfig:0.2.0"
}

Kotlin DSL:

repositories {
    // ...
    maven {
        name = "Nova Committee - Release"
        url = uri("https://maven.nova-committee.cn/releases/")
    }
    maven {
        name = "Nova Committee - Snapshot"
        url = uri("https://maven.nova-committee.cn/snapshots/")
    }
}

dependencies {
    // ...
    implementation("io.github.prismwork:prismconfig:0.2.0:all")
    // Or use the slim jar if you have the libraries included in your project (Gson, Jankson...)
    // implementation("io.github.prismwork:prismconfig:0.2.0")
}

Prism Config by default provides serializers and deserializers for JSON (Gson), JSON5 (Jankson) and TOML 0.4.0 (toml4j).

To parse a config from string into object, you can do this:

String content;
MyConfig config = PrismConfig.getInstance().serialize(
        MyConfig.class,
        content,
        DefaultSerializers.getInstance().json5(MyConfig.class) // We assume that your config is written in JSON5
);

To parse a config from object into string, you can do this:

MyConfig content;
String config = PrismConfig.getInstance().deserialize(
        MyConfig.class,
        content,
        DefaultDeserializers.getInstance().json5(MyConfig.class) // We assume that your config is written in JSON5
);

You can also write it to a file:

MyConfig content;
File configFile;
PrismConfig.getInstance().deserializeAndWrite(
        MyConfig.class,
        content,
        DefaultDeserializers.getInstance().json5(MyConfig.class), // We assume that your config is written in JSON5
        configFile
);

To write your own serializer/deserializer, you can use the following code (we use serializing as an example):

String content;
PrismConfig.getInstance().serialize(
        MyConfig.class,
        content,
        (string) -> {
            // Do your own parsing here
        }
);

Libraries Used

  • Jankson by falkreon, licensed under MIT.
  • Gson by Google, licensed under Apache-2.0.
  • toml4j by Moandji Ezana, licensed under MIT.

Modrinth is open source.

main@4bafae8

© Rinth, Inc.

Company

TermsPrivacyRulesCareers

Resources

SupportBlogDocsStatus

Interact

Discord X (Twitter) Mastodon Crowdin
Get Modrinth App Settings
NOT AN OFFICIAL MINECRAFT SERVICE. NOT APPROVED BY OR ASSOCIATED WITH MOJANG OR MICROSOFT.