Config

基本信息

属性 值
类名 myessentials.Config
类型 class extends ConfigTemplate
单例 public static final Config instance = new Config()
配置项 3(全部在 general 分类)
启用版本 Minecraft 1.7.10

功能

本 mod 全部配置项的声明,继承 ConfigTemplate 的绑定机制。

配置名 类型 默认值 说明
maintenanceMode Boolean false 允许切换维护模式
maintenanceModeMessage String Server is in maintenance mode currently. Please come back later. 维护模式下的提示
localization String en_US 本地化文件名(不含扩展名)

实现要点

  • 3 个配置项的 category 全部是 "general"——本 mod 没有第二个分类。
  • instance 是 static final 且在字段初始化时即 new, 即类加载即创建,不等 init。
  • instance 本身 extends ConfigTemplate,但源码中没有 @Config 注解、没有 getModID() 覆写、没有 addBinding 调用—— 3 个 ConfigProperty 仅靠反射被 ConfigTemplate.bind() 发现 (见 ConfigTemplate)。
  • maintenanceMode 与 maintenanceModeMessage 仅被 PlayerTracker 消费;localization 被主类用于 Local 的构造。

[!WARNING] localization 的描述文本是从 MyTown 复制来的 注释原文: Loaded from config/MyTown/localization/ first, then from the jar, ... 但本 mod 的实际路径是 config/MyEssentials-Core/localization/ (见主类的 Constants.CONFIG_FOLDER)。配置界面上的这段说明是错的。

相关条目