Skip to content

Commit

Permalink
Fix race condition in update notifyer
Browse files Browse the repository at this point in the history
  • Loading branch information
KonaeAkira committed Jun 20, 2022
1 parent bfb06cc commit 26e6a75
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/me/xmrvizzy/skyblocker/utils/UpdateChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class UpdateChecker {
public static Matcher matcher;
public static VersionNumber localVersion = null;
public static VersionNumber latestVersion = null;
public static boolean shouldUpdate(){

public static void checkVersion(){
if (SkyblockerConfig.get().general.enableUpdateNotification){
new Thread(() -> {
try{
Expand All @@ -47,18 +48,17 @@ public static boolean shouldUpdate(){
}
}).start();
}
return shouldUpdate;
}

public static void init(){
checkVersion();
SkyblockEvents.JOIN.register(() -> {
if (shouldUpdate()) {
if (shouldUpdate) {
TranslatableText linkMessage = new TranslatableText("skyblocker.update.update_message");
TranslatableText linkMessageEnding = new TranslatableText("skyblocker.update.update_message_end");
TranslatableText link = new TranslatableText("skyblocker.update.update_link");
TranslatableText hoverText = new TranslatableText("skyblocker.update.hover_text");
linkMessage.append(link.styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://modrinth.com/mod/skyblocker-liap/versions")).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)))).append(linkMessageEnding);

MinecraftClient.getInstance().player.sendMessage(linkMessage, false);
}
});
Expand Down

0 comments on commit 26e6a75

Please sign in to comment.