检测到BotName变动时提示重置数据文件

This commit is contained in:
SerendipityR 2022-08-20 23:01:24 +08:00 committed by GitHub
parent d6b5bb29ff
commit d59473286e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 3 deletions

View File

@ -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-========================");

View File

@ -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<String> botRegPasswords;
public static HashMap<String,String> 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) {

View File

@ -1,2 +1 @@
Data:
- ""
Data: []