1.0.1:Fix bug:[21:01:10 INFO]: [PBL] §a========================================

[21:01:10 INFO]: [PBL] §ePlayerBlockLife v1.0.1-1.20.4 已启用
              [21:01:10 INFO]: [PBL] §e作者: [YourName]
              [21:01:10 INFO]: [PBL] §a========================================
This commit is contained in:
xiaobai
2026-02-13 22:03:17 +08:00
parent f899540449
commit 8b502459b0
10 changed files with 737 additions and 138 deletions

View File

@@ -77,10 +77,41 @@ public class ConfigManager {
*/
private void updateConfig(int fromVersion, int toVersion) {
if (fromVersion == 1 && toVersion == 2) {
// 示例:添加新配置
if (!config.contains("new-feature.enabled")) {
config.set("new-feature.enabled", true);
config.set("new-feature.duration", 60);
// 添加自动生成配置
if (!config.contains("auto-generation.enabled")) {
config.set("auto-generation.enabled", true);
config.set("auto-generation.require_open_sky", true);
config.set("auto-generation.max_attempts", 50);
config.set("auto-generation.on_failure", "notify");
}
// 添加命令启用配置
if (!config.contains("commands.setlifeblocks.enabled")) {
config.set("commands.setlifeblocks.enabled", true);
config.set("commands.setlifeblocks.allow_self_use", true);
config.set("commands.setlifeblocks.allow_admin_use", true);
config.set("commands.checklifeblocks.enabled", true);
config.set("commands.checklifeblocks.allow_self_use", true);
config.set("commands.checklifeblocks.allow_admin_use", true);
config.set("commands.pblreload.enabled", true);
config.set("commands.pblreload.admin_only", true);
config.set("commands.pbldelete.enabled", true);
config.set("commands.pbldelete.admin_only", true);
config.set("commands.pblrevive.enabled", true);
config.set("commands.pblrevive.admin_only", true);
config.set("commands.pblstats.enabled", true);
config.set("commands.pblstats.admin_only", true);
}
// 更新消息配置
if (!config.contains("messages.use_external_file")) {
config.set("messages.use_external_file", true);
config.set("messages.external_file", "messages.yml");
}
// 更新版本号
@@ -202,7 +233,58 @@ public class ConfigManager {
return getConfig().getBoolean("protection.protect_from_pistons", true);
}
// 自动生成配置获取方法
public boolean isAutoGenerationEnabled() {
return getConfig().getBoolean("auto-generation.enabled", true);
}
public boolean isRequireOpenSky() {
return getConfig().getBoolean("auto-generation.require_open_sky", true);
}
public int getMaxAttempts() {
return getConfig().getInt("auto-generation.max_attempts", 50);
}
public String getOnFailureAction() {
return getConfig().getString("auto-generation.on_failure", "notify");
}
// 命令启用配置获取方法
public boolean isCommandEnabled(String commandName) {
return getConfig().getBoolean("commands." + commandName + ".enabled", true);
}
public boolean isSelfUseAllowed(String commandName) {
return getConfig().getBoolean("commands." + commandName + ".allow_self_use", true);
}
public boolean isAdminUseAllowed(String commandName) {
return getConfig().getBoolean("commands." + commandName + ".allow_admin_use", true);
}
public boolean isAdminOnly(String commandName) {
return getConfig().getBoolean("commands." + commandName + ".admin_only", false);
}
// 消息文件配置获取方法
public boolean useExternalMessageFile() {
return getConfig().getBoolean("messages.use_external_file", true);
}
public String getExternalMessageFileName() {
return getConfig().getString("messages.external_file", "messages.yml");
}
public String getMessage(String path, String defaultValue) {
// 优先从外部消息文件获取
if (useExternalMessageFile()) {
// 这里应该调用MessageManager来获取消息
// 暂时返回默认值MessageManager会处理具体逻辑
return defaultValue;
}
// 从config.yml获取
String message = getConfig().getString("messages." + path, defaultValue);
if (message != null) {
message = message.replace("&", "§");