Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
1. 修复一个错误的拼写
2. 优化配置文件的检查功能的代码可读性
  • Loading branch information
stevei5mc committed May 20, 2024
1 parent c6d9055 commit 588f29e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
33 changes: 15 additions & 18 deletions src/main/java/cn/stevei5mc/NewTipsVariables/utils/ConfigUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,24 @@ public class ConfigUtils {
public static int ccvt = Main.getInstance().getConfig().getInt("version"); //config.yml
public static int cpvt = Main.getInstance().getConfigInPlayer().getInt("version"); //player.yml
public static int csvt = Main.getInstance().getConfigInServer().getInt("version"); //server.yml

public static void checkVersion() {
if (ccvl > csvl) {
Main.getInstance().getLogger().warning("§econfig.yml 版本不是最新版");
} else if (ccvl < csvl) {
Main.getInstance().getLogger().error("§cconfig.yml 版本出现了错误");
} else {
Main.getInstance().getLogger().info("§aconfig.yml 版本是最新版");
}
if (cpvl > cpvt) {
Main.getInstance().getLogger().warning("§eplayer.yml 版本不是最新版");
} else if (cpvl < cpvt) {
Main.getInstance().getLogger().error("§cplayer.yml 版本出现了错误");
} else {
Main.getInstance().getLogger().info("§aplayer.yml 版本是最新版");
runCheck("config.yml", ccvl, ccvt);
runCheck("player.yml", cpvl, cpvt);
runCheck("server.yml", csvl, csvt);
}

public static void runCheck(String name, int latestVersion, int currentVersion) {
Main.getInstance().getLogger().info(name + " §aversion: "+ currentVersion);
if (currentVersion == 0) {
currentVersion = 114514;//防止有人误把配置文件中的version配置项,如果无法获取数据则输入一个最大数
}
if (csvt > csvt) {
Main.getInstance().getLogger().warning("§eserver.yml 版本不是最新版");
} else if (csvt < csvt) {
Main.getInstance().getLogger().error("§cserver.yml 版本出现了错误");
if (currentVersion == latestVersion) {
Main.getInstance().getLogger().info(name + " §a版本是最新版");
} else if (currentVersion < latestVersion) {
Main.getInstance().getLogger().warning(name + " §e版本不是最新版, 请及时更新配置文件");
} else {
Main.getInstance().getLogger().info("§aserver.yml 版本是最新版");
Main.getInstance().getLogger().error(name + " §c版本出现了错误,需要修复配置文件");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class LoadSupportPlugins{
public static boolean pl6 = false;
public static boolean pl7 = false;
//加载相关插件的变量时的提示
public static String perfix = "§7[§cDEBUG§7] ";
public static String successMsg = perfix+"§a找到插件§e【§b{0}§e】§a相关变量已加载";
public static String failureMsg = perfix+"§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试";
public static String prefix = "§7[§cDEBUG§7] ";
public static String successMsg = prefix+"§a找到插件§e【§b{0}§e】§a相关变量已加载";
public static String failureMsg = prefix+"§c无法找到插件§e【§b{0}§e】§c相关变量加载失败,请安装相关插件再试";
//需要加载的变量的插件
public static void loadSupportVariables(Player player) {
boolean debug = Main.debug;
Expand Down

1 comment on commit 588f29e

@stevei5mc
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

补充:
是配置文件的版本检查功能

Please sign in to comment.