mirror of
https://github.com/SerendipityR-2022/EndMinecraftPlusV2.git
synced 2024-10-31 20:08:00 +00:00
检测到BotName变动时提示重置数据文件
This commit is contained in:
parent
d6b5bb29ff
commit
d59473286e
@ -8,7 +8,7 @@ import cn.serendipityr.EndMinecraftPlusV2.VersionControl.AttackManager;
|
|||||||
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.ProtocolLibs;
|
import cn.serendipityr.EndMinecraftPlusV2.VersionControl.ProtocolLibs;
|
||||||
|
|
||||||
public class EndMinecraftPlusV2 {
|
public class EndMinecraftPlusV2 {
|
||||||
public static String ver = "1.2.2";
|
public static String ver = "1.2.3";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("========================-Forked by SerendipityR-========================");
|
System.out.println("========================-Forked by SerendipityR-========================");
|
||||||
|
@ -7,17 +7,39 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class DataUtil {
|
public class DataUtil {
|
||||||
|
public static boolean notModify = false;
|
||||||
public static List<String> botRegPasswords;
|
public static List<String> botRegPasswords;
|
||||||
public static HashMap<String,String> botRegPasswordsMap = new HashMap<>();
|
public static HashMap<String,String> botRegPasswordsMap = new HashMap<>();
|
||||||
|
|
||||||
public static void loadData() {
|
public static void loadData() {
|
||||||
File dataFile = new File("data.yml");
|
File dataFile = new File("data.yml");
|
||||||
|
|
||||||
if (dataFile.exists()) {
|
if (dataFile.exists()) {
|
||||||
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
|
YamlConfiguration data = YamlConfiguration.loadConfiguration(dataFile);
|
||||||
botRegPasswords = data.getStringList("Data");
|
botRegPasswords = data.getStringList("Data");
|
||||||
botRegPasswords.remove("");
|
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 {
|
} else {
|
||||||
botRegPasswords = new ArrayList<>();
|
botRegPasswords = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -48,6 +70,10 @@ public class DataUtil {
|
|||||||
|
|
||||||
data.set("Data", dataList);
|
data.set("Data", dataList);
|
||||||
|
|
||||||
|
if (!notModify) {
|
||||||
|
data.set("LastBotName", ConfigUtil.BotName);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data.save(dataFile);
|
data.save(dataFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -1,2 +1 @@
|
|||||||
Data:
|
Data: []
|
||||||
- ""
|
|
Loading…
Reference in New Issue
Block a user