Skip to content

Commit

Permalink
fix /lang without argument bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCai2019 committed Feb 2, 2023
1 parent 125314e commit fde329c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/cartoland/utilities/JsonHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ public static String command(long userID, String typeCommandName)
lastUse(userID);
StringBuilder builder = new StringBuilder();
builder.append(file.getString(typeCommandName + ".begin")); //開頭
JSONArray dotListArray = file.getJSONArray(typeCommandName + ".list");

String jsonKey = typeCommandName + ".list";
JSONObject hasKeyFile;
if (file.has(jsonKey)) //如果有這個key
hasKeyFile = file;
else if (englishFile.has(jsonKey)) //預設使用英文
hasKeyFile = englishFile;
else
return file.getString(typeCommandName + ".fail");

JSONArray dotListArray = hasKeyFile.getJSONArray(jsonKey);
int dotListArrayLength = dotListArray.length();
for (int i = 0; i < dotListArrayLength; i++) //所有.list內的內容
builder.append(dotListArray.getString(i)).append(' ');
Expand All @@ -57,11 +67,11 @@ public static String command(long userID, String typeCommandName)
public static String command(long userID, String typeCommandName, String argument)
{
lastUse(userID);
String fileKey = typeCommandName + ".name." + argument;
String jsonKey = typeCommandName + ".name." + argument;
JSONObject hasKeyFile;
if (file.has(fileKey)) //如果有這個key
if (file.has(jsonKey)) //如果有這個key
hasKeyFile = file;
else if (englishFile.has(fileKey)) //預設使用英文
else if (englishFile.has(jsonKey)) //預設使用英文
hasKeyFile = englishFile;
else
return file.getString(typeCommandName + ".fail");
Expand Down

0 comments on commit fde329c

Please sign in to comment.