From d59473286e2a18b1bea42d01fe38efa90faaae7d Mon Sep 17 00:00:00 2001 From: SerendipityR <48401197+SerendipityR-2022@users.noreply.github.com> Date: Sat, 20 Aug 2022 23:01:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=88=B0BotName=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E6=8F=90=E7=A4=BA=E9=87=8D=E7=BD=AE=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EndMinecraftPlusV2.java | 2 +- .../EndMinecraftPlusV2/Tools/DataUtil.java | 26 +++++++++++++++++++ src/data.yml | 3 +-- 3 files changed, 28 insertions(+), 3 deletions(-) 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