类 ConfigManager
java.lang.Object
com.playerblocklife.ConfigManager
配置管理器 - 负责加载、保存和管理插件的配置文件
主要功能包括:
- 加载和验证配置文件
- 配置版本检查和自动更新
- 提供类型安全的配置项访问方法
- 处理配置文件的保存和重载
- 管理SkinsRestorer插件集成配置
- 支持多种皮肤来源的优先级配置
SkinsRestorer配置支持:
skin.source:皮肤来源优先级(skinsrestorer/player_profile/local_cache)skin.use-skinsrestorer:是否启用SkinsRestorer支持skin.cache.expire_days:皮肤缓存过期时间- 默认配置已优化,优先使用SkinsRestorer以支持离线服务器
- 从以下版本开始:
- 1.0.0
- 版本:
- 2.1.0
- 作者:
- xiaobai
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明intintintintorg.bukkit.configuration.file.FileConfiguration获取配置对象intgetDepth()intintgetMessage(String path, String defaultValue) int获取皮肤来源配置intbooleanisAdminOnly(String commandName) booleanisAdminUseAllowed(String commandName) booleanbooleanbooleanbooleanbooleanbooleanisCommandEnabled(String commandName) booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisSelfUseAllowed(String commandName) booleanvoid加载插件配置void重新加载配置文件void保存当前配置到文件booleanboolean检查是否启用SkinsRestorer插件支持
-
构造器详细资料
-
ConfigManager
构造一个新的配置管理器- 参数:
plugin- 插件主类实例,用于访问插件相关功能
-
-
方法详细资料
-
loadConfig
public void loadConfig()加载插件配置执行以下操作:
- 确保插件数据文件夹存在
- 如果配置文件不存在,从JAR中复制默认配置
- 调用reloadConfig()重新加载配置
- 另请参阅:
-
reloadConfig
public void reloadConfig()重新加载配置文件执行以下操作:
- 从磁盘重新加载配置文件
- 加载JAR中的默认配置作为后备
- 检查配置版本并进行必要的更新
- 另请参阅:
-
saveConfig
public void saveConfig()保存当前配置到文件将内存中的配置数据写入到config.yml文件中。 如果保存失败,会记录错误日志。
- 抛出:
IOException- 如果文件写入失败
-
getConfig
public org.bukkit.configuration.file.FileConfiguration getConfig()获取配置对象如果配置对象为null,会自动调用reloadConfig()加载配置。
- 返回:
- 当前的FileConfiguration配置对象
- 另请参阅:
-
getBlocksPerPlayer
public int getBlocksPerPlayer() -
getSpreadRange
public int getSpreadRange() -
getMinDistance
public int getMinDistance() -
getDepth
public int getDepth() -
getBlockMaterial
-
isDieWhenBlocksGone
public boolean isDieWhenBlocksGone() -
isBecomeSpectator
public boolean isBecomeSpectator() -
isHealthSystemEnabled
public boolean isHealthSystemEnabled() -
isSkinSystemEnabled
public boolean isSkinSystemEnabled() -
getSkinSource
获取皮肤来源配置支持的皮肤来源:
- skinsrestorer:优先从SkinsRestorer插件获取皮肤纹理数据
- 推荐用于离线服务器
- 支持玩家自定义皮肤
- 避免默认Steve皮肤问题
- player_profile:优先使用Bukkit的PlayerProfile API
- 需要玩家在线验证
- 适合在线服务器
- 支持Mojang官方皮肤
- local_cache:优先从本地缓存加载皮肤数据
- 减少网络请求
- 提高加载速度
- 支持离线使用
默认配置已将此值设为"skinsrestorer",以优化离线服务器体验。
- 返回:
- 皮肤来源配置值
- 另请参阅:
- skinsrestorer:优先从SkinsRestorer插件获取皮肤纹理数据
-
useSkinsRestorer
public boolean useSkinsRestorer()检查是否启用SkinsRestorer插件支持当此方法返回true时,插件将:
- 优先从SkinsRestorer插件获取玩家皮肤纹理
- 支持离线服务器获取玩家自定义皮肤
- 避免方块总是显示默认Steve皮肤的问题
- 使用反射安全调用SkinsRestorer API,无需硬依赖
默认配置已将此值设为true,以优化离线服务器体验。
- 返回:
- 如果启用SkinsRestorer支持返回true,否则返回false
- 另请参阅:
-
getCacheExpireDays
public int getCacheExpireDays() -
isAutoSaveEnabled
public boolean isAutoSaveEnabled() -
getAutoSaveInterval
public int getAutoSaveInterval() -
getStorageType
-
isBroadcastOnBlockBreak
public boolean isBroadcastOnBlockBreak() -
isBroadcastOnPlayerDeath
public boolean isBroadcastOnPlayerDeath() -
getBroadcastRange
public int getBroadcastRange() -
isGiveExpReward
public boolean isGiveExpReward() -
getExpRewardAmount
public int getExpRewardAmount() -
isProtectFromExplosions
public boolean isProtectFromExplosions() -
isProtectFromFire
public boolean isProtectFromFire() -
isProtectFromPistons
public boolean isProtectFromPistons() -
isAutoGenerationEnabled
public boolean isAutoGenerationEnabled() -
isRequireOpenSky
public boolean isRequireOpenSky() -
getMaxAttempts
public int getMaxAttempts() -
getOnFailureAction
-
isCommandEnabled
-
isSelfUseAllowed
-
isAdminUseAllowed
-
isAdminOnly
-
useExternalMessageFile
public boolean useExternalMessageFile() -
getExternalMessageFileName
-
getMessage
-