diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java index bdb1b99d2..2f97e10e4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/update/ThreadUpdateChecker.java @@ -82,5 +82,7 @@ public class ThreadUpdateChecker extends Thread{ ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME+" is up to date!"); } } + + UpdateChecker.threadFinished = true; } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java index 503283d2a..3a0faeaec 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/update/UpdateChecker.java @@ -31,14 +31,11 @@ public class UpdateChecker{ public static boolean needsUpdateNotify; public static int updateVersionInt; public static String updateVersionString; - - private static boolean notified = false; - private static int ticksElapsedBeforeInfo; + public static boolean threadFinished = false; public UpdateChecker(){ if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()){ ActuallyAdditions.LOGGER.info("Initializing Update Checker..."); - new ThreadUpdateChecker(); MinecraftForge.EVENT_BUS.register(this); } @@ -47,23 +44,17 @@ public class UpdateChecker{ @SideOnly(Side.CLIENT) @SubscribeEvent(receiveCanceled = true) public void onTick(TickEvent.ClientTickEvent event){ - //Don't notify directly to prevent the Message getting lost in Spam on World Joining - if(!notified && Minecraft.getMinecraft().player != null){ - ticksElapsedBeforeInfo++; - if(ticksElapsedBeforeInfo >= 800){ - EntityPlayer player = Minecraft.getMinecraft().player; - if(UpdateChecker.checkFailed){ - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.failed"))); - notified = true; - } - else if(UpdateChecker.needsUpdateNotify){ - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.generic"))); - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString))); - player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK))); - notified = true; - } - ticksElapsedBeforeInfo = 0; + if(Minecraft.getMinecraft().player != null){ + EntityPlayer player = Minecraft.getMinecraft().player; + if(UpdateChecker.checkFailed){ + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.failed"))); } + else if(UpdateChecker.needsUpdateNotify){ + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.generic"))); + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.versionCompare", ActuallyAdditions.VERSION, UpdateChecker.updateVersionString))); + player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localizeFormatted("info."+ActuallyAdditions.MODID+".update.buttons", UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK))); + } + if(threadFinished) MinecraftForge.EVENT_BUS.unregister(this); } } } \ No newline at end of file