Skip to content

Commit

Permalink
修复更新通知从不发送的问题
Browse files Browse the repository at this point in the history
Fixes #239
  • Loading branch information
Xujiayao committed Jun 27, 2024
1 parent 49c777b commit dec3d52
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/com/xujiayao/discord_mc_chat/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static String checkUpdate(boolean isManualCheck) {

String minecraftVersion = DetectedVersion.tryDetectVersion().getName();

CONFIG.latestVersion = "";
String latestVersion = "";
String latestChangelog = "";

JsonArray versions = new Gson().fromJson(result, JsonObject.class).getAsJsonArray("versions");
Expand Down Expand Up @@ -175,26 +175,28 @@ public static String checkUpdate(boolean isManualCheck) {
}

if (isCompatible) {
CONFIG.latestVersion = object.get("version").getAsString();
latestVersion = object.get("version").getAsString();
latestChangelog = object.get("changelog").getAsString();
ConfigManager.update();
break;
}
}

StringBuilder message = new StringBuilder();

if (!CONFIG.latestVersion.equals(VERSION)) {
if (CONFIG.latestCheckTime > (System.currentTimeMillis() - 172800000) && !isManualCheck) {
if (!latestVersion.equals(VERSION)) {
if (latestVersion.equals(CONFIG.latestVersion)
&& CONFIG.latestCheckTime > (System.currentTimeMillis() - 172800000)
&& !isManualCheck) {
return "";
}

CONFIG.latestVersion = latestVersion;
CONFIG.latestCheckTime = System.currentTimeMillis();
ConfigManager.update();

message.append(Translations.translate("utils.utils.cUpdate.newVersionAvailable"));
message.append("\n\n");
message.append("**Discord-MC-Chat ").append(VERSION).append(" -> ").append(CONFIG.latestVersion).append("**");
message.append("**Discord-MC-Chat ").append(VERSION).append(" -> ").append(latestVersion).append("**");
message.append("\n\n");
message.append(Translations.translate("utils.utils.cUpdate.downloadLink"));
message.append("\n\n");
Expand All @@ -207,6 +209,7 @@ public static String checkUpdate(boolean isManualCheck) {

return message.toString();
} else {
CONFIG.latestVersion = latestVersion;
CONFIG.latestCheckTime = System.currentTimeMillis();
ConfigManager.update();

Expand Down

0 comments on commit dec3d52

Please sign in to comment.