JarJar 配置文件
基本信息
| 属性 | 值 |
|---|---|
| 文件路径 | <minecraft>/config/jarjar.properties |
| 读取类 | com.mitchej123.jarjar.Config |
| 写回时机 | 缺失或不存在 → 写默认值 |
| Properties 库 | java.util.Properties |
Config 在 static 块读取配置,并立即把读取结果写回文件(保证文件存在)。它不使用 Forge 的 Configuration 体系,因为该类需要在其它 deobMod 加载之前早期读取。
读取字段
maxThreads
| 类型 | 默认 | 含义 |
|---|---|---|
int |
-1 → 退化为 Runtime.getRuntime().availableProcessors() |
DiscoveryPool 共享 ForkJoinPool 的并行度 |
final int threads = Integer.parseInt(config.getProperty("maxThreads", "-1"));
maxThreads = threads > 0 ? threads : Runtime.getRuntime().availableProcessors();
enableSortingIndexOverrides
| 类型 | 默认 | 含义 |
|---|---|---|
boolean |
true |
是否允许用 SortingIndex.<coremod class>=<n> 覆写 coremod 加载顺序 |
写入时自动补默认值:
config.putIfAbsent("enableSortingIndexOverrides", "true");
sortingIndexOverrides
| 类型 | 默认 | 含义 |
|---|---|---|
Map<String, Integer> |
空 | 凡是 keys 以 SortingIndex. 开头的条目,将 <coremod class>=<n> 收集到 Map |
读取逻辑:
final String sortingIndex = "SortingIndex.";
final int subStrIdx = sortingIndex.length();
for (String name : config.stringPropertyNames()) {
if (name.startsWith(sortingIndex)) {
final String coremodClass = name.substring(subStrIdx);
final int sortOrderOverride = Integer.parseInt(config.getProperty(name).trim());
overrides.put(coremodClass, sortOrderOverride);
}
}
非法整数会被跳过并打 WARN。
示例文件
maxThreads=8
enableSortingIndexOverrides=true
SortingIndex.com.mitchej123.hodgepodge.core.HodgepodgeCore=1
SortingIndex.some.other.coremod=5
注释行(JProperties 不支持注释,但 Config 不解析 #,所以会被当作属性名并落入 stringPropertyNames)。建议使用 Properties 风格的真实注释格式。
写回
try (Writer r = new BufferedWriter(new FileWriter(configLocation))) {
config.store(r, "Coremod SortingIndex override: SortingIndex.<coremod class>=<number> sets a coremod's load order.\nExample: SortingIndex.com.mitchej123.hodgepodge.core.HodgepodgeCore=1");
}
Properties.store 会自动写入当前时间戳和注释行,但保留 key 与 value。
相关条目
- 并行 mod 发现 -
maxThreads直接控制 DiscoveryPool 线程数 - Hodgepodge 排序兜底 - 与 SortingIndex 共享同一套排序接口
- JarUtil 嵌套抽取与版本识别 -
applyConfiguredSortOrder真正消费 SortingIndex 覆写