AnnotatedProperties
基本信息
| 属性 | 值 |
|---|---|
| 位置 | module-common/src/main/java/…/config/ |
| 类数 | 4(AnnotatedProperties、PropertyCollection、PropertyToken、ConfigUtil) |
| 配置格式 | config/unimixins.properties |
| 启用版本 | Minecraft 1.7.10 |
UniMixins 自研的配置框架,与 Forge 的 @Config / .cfg 体系无关。
4 个类
| 类 | 作用 |
|---|---|
AnnotatedProperties |
解析器:load(File, Class<?>) + 注解定义 |
PropertyCollection |
配置项集合 |
PropertyToken |
单个配置项(键、默认值、分类、注释) |
ConfigUtil |
入口,见 ConfigUtil |
注解
配置项通过 @AnnotatedProperties.* 系列注解声明,例:
@AnnotatedProperties.ConfigString(def = "true",
com = "Throw an error if an invalid combination of modules is detected. …",
cat = "_common")
public static boolean enableIntegrityChecks;
| 注解后缀 | 适用类型 |
|---|---|
ConfigString |
boolean(名字有误导性,见下) |
⚠️ ConfigString 用于 boolean 字段(见 SanityCheckConfig)。
注解名里的 String 不表示目标类型是字符串,
按名字推断类型会写错。
⚠️ 所有配置字段都是 public static(非 final),
由解析器反射赋值 —— 因此不能声明为 final。
分类约定
cat 决定配置项在 unimixins.properties 中的分组。
本仓出现 3 个分组名:_common(仅 SanityCheckConfig)、
compat、gtnhmixins。
所有模块共用同一份 unimixins.properties,
且 module-common 会被 relocate 成每个模块的私有副本,
但配置语义全局唯一。
已知配置项
本仓仅 2 个配置类,共 4 个配置项:
| 配置类 | 项 | 默认 | 分组 |
|---|---|---|---|
| SanityCheckConfig | enableIntegrityChecks |
true |
_common |
| CompatConfig | enableRemapper |
true |
compat |
| CompatConfig | enhanceCrashReports |
true |
compat |
| CompatConfig | improveInitPhaseDetection |
true |
compat |
⚠️ 实际只有 SanityCheckConfig 用 cat = "_common";
CompatConfig 用 cat = "compat",GTNHMixinsConfig 用 cat = "gtnhmixins"。
三者全用 ConfigString 注解且默认值全是 true。
⚠️ GTNHMixinsConfig 是第 3 个配置类(1 项:
enableLegacyGTNHMixinExtrasPackage),属
module-gtnhmixins。它同样用
@AnnotatedProperties.ConfigString,故总计 4 个配置项、3 个配置类。
相关条目
- ConfigUtil - 加载入口
- SanityCheckConfig - 配置类 1
- CompatConfig - 配置类 2
- GTNHMixinsConfig - 配置类 3(独立机制)
- module-common - 本框架所属模块