mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
unregister the update checker after finishing
since this is a tick handler keeping it registered is probably a bad idea.
This commit is contained in:
parent
2584bb9cf4
commit
a10999736a
2 changed files with 13 additions and 20 deletions
|
@ -82,5 +82,7 @@ public class ThreadUpdateChecker extends Thread{
|
|||
ActuallyAdditions.LOGGER.info(ActuallyAdditions.NAME+" is up to date!");
|
||||
}
|
||||
}
|
||||
|
||||
UpdateChecker.threadFinished = true;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue