LibJF/docs/config/README.md

2.0 KiB

About

LibJF Config is a modular config library. Generally, using a combination of its modules is recommended. On the following pages, the modules of libjf-config are explained in more detail. If you just want to get started, a quick setup example for a client-side mod using the compiler plugin can be seen below:

settings.gradle:

pluginManagement {
    repositories {
        maven {
            name = 'LibJF'
            url = 'https://maven.frohnmeyer-wds.de/artifacts'
        }
    }
}

build.gradle:

plugins {
    id 'io.gitlab.jfronny.libjf.libjf-config-compiler-plugin' version 'VERSION'
}

repositories {
    maven { url 'https://maven.frohnmeyer-wds.de/artifacts' }
}

dependencies {
    include modImplementation("io.gitlab.jfronny.libjf:libjf-config-core-v1:${project.libjf_version}")
    include modRuntimeOnly("io.gitlab.jfronny.libjf:libjf-config-ui-tiny-v1:${project.libjf_version}")
    include("io.gitlab.jfronny.libjf:libjf-base:${project.libjf_version}")

    modLocalRuntime("io.gitlab.jfronny.libjf:libjf-config-reflect-v1:${project.libjf_version}")
}

task injectCompiledConfig(type: io.gitlab.jfronny.libjf.config.plugin.ConfigInjectTask, dependsOn: jar) {
    from jar
    modId = archivesBaseName
    archiveClassifier = 'config-inject'
    destinationDirectory = file("${project.buildDir}/devlibs")
}

remapJar {
    dependsOn injectCompiledConfig
    input = injectCompiledConfig.archiveFile
}

loom {
    mods {
        register(name, {
            sourceSet sourceSets.main
        })
    }
}

fabric.mod.json:

{
  "entrypoints": {
    "libjf:config": ["Your config class here"]
  }
}

Config class:

@JfConfig
public class ConfigExample {
    @Entry public static boolean someEntry = true;
}

en_us.json:

{
  "modid.jfconfig.title": "Your Mod",
  "modid.jfconfig.someEntry": "Some Entry",
  "modid.jfconfig.someEntry.tooltip": "Some comment"
}

I also recommend adding ModMenu in order to more easily test your config in dev.