This commit is contained in:
BRanulf 2025-06-10 22:25:05 +08:00
parent 8a13d8e9ec
commit 0de2bcd15a
2 changed files with 8 additions and 8 deletions

View File

@ -16,9 +16,9 @@ import java.util.List;
public class ConfigFile {
private static final JSONParser parser = new JSONParser();
private static final String CONFIG_FILE_NAME = "commands.json";
private static final String CONFIG_FILE_NAME = "commands1.json"; // 改下名称防止冲突不过我也不确定会不会有人同时加俩版本
// Read commands.json, convert it to an array, and append A JSON OBJECT
// Read commands1.json, convert it to an array, and append A JSON OBJECT
public static void appendToFile(JSONObject jsonObject) {
JSONArray array = getJsonArrayFromFile();
if (array == null) {
@ -78,7 +78,7 @@ public class ConfigFile {
}
// overwrites current commands.json w/ updated jsonArray
// overwrites current commands1.json w/ updated jsonArray
private static void writeToFile(JSONArray jsonArray) {
FileWriter fileWriter = null;
try {
@ -101,7 +101,7 @@ public class ConfigFile {
}
}
// parses commands.json into JSONArray
// parses commands1.json into JSONArray
private static JSONArray getJsonArrayFromFile() {
try (FileReader reader = new FileReader(CONFIG_FILE_NAME)) {
Object obj = parser.parse(reader);
@ -116,17 +116,17 @@ public class ConfigFile {
return new JSONArray();
}
} catch (IOException e) {
System.out.println("Commands.json文件不存在或读取错误。返回null。");
System.out.println("commands1.json文件不存在或读取错误。返回null。");
return null;
} catch (ParseException e) {
System.err.println("解析 commands.json 时出错:" + e.getMessage());
System.err.println("解析 commands1.json 时出错:" + e.getMessage());
e.printStackTrace();
return new JSONArray();
}
}
// parses commands.json into
// parses commands1.json into
public static ArrayList<JSONObject> getArrayFromJsonFile() {
JSONArray array = getJsonArrayFromFile();
if (array == null) {

View File

@ -97,7 +97,7 @@ public class ButtonGUI extends LightweightGuiDescription {
commandListPanel.add(commandEntryPanel, 0, yOffset, 18, 1);
yOffset += 1;
} else {
System.err.println("在 commands.json 中跳过格式错误的命令对象:" + object.toJSONString());
System.err.println("在 commands1.json 中跳过格式错误的命令对象:" + object.toJSONString());
}
}
}