Prism Config 图标

Prism Config

作者:rebot | 分类:模组

价格:0 墨喵币 下载量:0 点赞:0 版本 0.2.0
本资源为搬运资源,原资源地址: https://modrinth.com/mod/prism-config
资源信息

Minecraft 版本: 1.14 1.14.1 1.14.2 1.14.3 1.14.4 1.15 1.15.1 1.15.2 1.16 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.17 1.17.1 1.18 1.18.1 1.18.2 1.19 1.19.1 1.19.2 1.19.3

平台: fabric quilt

标签: library

资源介绍
Icon ![java8](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@2/assets/cozy/built-with/java8_vector.svg) ![gradle](https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@2/assets/cozy/built-with/gradle_vector.svg) [![Release](https://img.shields.io/github/v/release/Prismwork/PrismConfig?style=for-the-badge&include_prereleases&sort=semver)][releases] 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 和外网直链高速下载! 用的人越多,下载的越快!
下载与版本
评论(0)
登录 后发表评论。

暂无评论,抢个沙发吧~

举报此资源

请登录后举报

🔥 相关推荐
Cinematic Hotbar

价格:0 墨喵币
下载量:0

查看详情
DonutRTP

价格:0 墨喵币
下载量:0

查看详情
Potions Stack

价格:0 墨喵币
下载量:0

查看详情
Speacs better apples

价格:0 墨喵币
下载量:0

查看详情