ConfigHandler

基本信息

属性 值
类名 amerifrance.guideapi.ConfigHandler
类型 class,全静态
配置文件 config/Guide-API/Guide-API.cfg
配置项 2
启用版本 Minecraft 1.7.10

功能

本 mod 全部配置项的声明与读取。

分类 配置名 字段 类型 默认值
Books canSpawnWithBooks canSpawnWithBooks boolean true
General enableLogging enableLogging boolean true

实现要点

  • 配置路径由 GuideAPI 拼装: new File(configDir + "/" + ModInformation.NAME + ".cfg"), 目录名与文件名都用 modName Guide-API(含连字符),非 modid。
  • 两个分类各有 addCustomCategoryComment 自定义注释。
  • canSpawnWithBooks 的注释明确说明 「Only affects books where the author enables the spawning feature」—— 即只对 book.spawnWithBook == true 的书生效,全局开关是叠加条件。
  • syncConfig() 结尾无条件 config.save(),即使无改动也写盘。
  • syncConfig() 未被任何地方调用除 init 之外: 源码中只有 ConfigHandler.init(...) 一处入口, 没有 Configuration 的 loadConfig / 监听重载机制。

相关条目