diff --git a/src/cn/serendipityr/EndMinecraftPlusV2/EndMinecraftPlusV2.java b/src/cn/serendipityr/EndMinecraftPlusV2/EndMinecraftPlusV2.java index 439dee7..65512a2 100644 --- a/src/cn/serendipityr/EndMinecraftPlusV2/EndMinecraftPlusV2.java +++ b/src/cn/serendipityr/EndMinecraftPlusV2/EndMinecraftPlusV2.java @@ -8,7 +8,7 @@ import cn.serendipityr.EndMinecraftPlusV2.VersionControl.AttackManager; import cn.serendipityr.EndMinecraftPlusV2.VersionControl.ProtocolLibs; public class EndMinecraftPlusV2 { - public static String ver = "1.2.2"; + public static String ver = "1.2.3"; public static void main(String[] args) { System.out.println("========================-Forked by SerendipityR-========================"); diff --git a/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java b/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java index 1c27c63..0baab17 100644 --- a/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java +++ b/src/cn/serendipityr/EndMinecraftPlusV2/Tools/DataUtil.java @@ -7,17 +7,39 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Scanner; public class DataUtil { + public static boolean notModify = false; public static List botRegPasswords; public static HashMap botRegPasswordsMap = new HashMap<>(); public static void loadData() { File dataFile = new File("data.yml"); + if (dataFile.exists()) { YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile); botRegPasswords = data.getStringList("Data"); botRegPasswords.remove(""); + + String lastBotName = data.getString("LastBotName"); + if (lastBotName != null && !ConfigUtil.BotName.equals(lastBotName)) { + LogUtil.doLog(-1, "检测到BotName已被修改,是否重置数据文件以使更改生效? [y/n]:", "DataUtil"); + Scanner scanner = new Scanner(System.in); + if (scanner.nextLine().contains("y")) { + if (dataFile.delete()) { + LogUtil.doLog(0, "数据文件已成功重置。", "DataUtil"); + } else { + LogUtil.doLog(0, "修改数据文件时出错,操作成功未完成。", "DataUtil"); + } + LogUtil.emptyLog(); + loadData(); + return; + } + + notModify = true; + LogUtil.emptyLog(); + } } else { botRegPasswords = new ArrayList<>(); } @@ -48,6 +70,10 @@ public class DataUtil { data.set("Data", dataList); + if (!notModify) { + data.set("LastBotName", ConfigUtil.BotName); + } + try { data.save(dataFile); } catch (IOException e) { diff --git a/src/data.yml b/src/data.yml index 3bca5df..8d15fb8 100644 --- a/src/data.yml +++ b/src/data.yml @@ -1,2 +1 @@ -Data: - - "" \ No newline at end of file +Data: [] \ No newline at end of file