mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +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!");
|
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 boolean needsUpdateNotify;
|
||||||
public static int updateVersionInt;
|
public static int updateVersionInt;
|
||||||
public static String updateVersionString;
|
public static String updateVersionString;
|
||||||
|
public static boolean threadFinished = false;
|
||||||
private static boolean notified = false;
|
|
||||||
private static int ticksElapsedBeforeInfo;
|
|
||||||
|
|
||||||
public UpdateChecker(){
|
public UpdateChecker(){
|
||||||
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()){
|
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()){
|
||||||
ActuallyAdditions.LOGGER.info("Initializing Update Checker...");
|
ActuallyAdditions.LOGGER.info("Initializing Update Checker...");
|
||||||
|
|
||||||
new ThreadUpdateChecker();
|
new ThreadUpdateChecker();
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
@ -47,23 +44,17 @@ public class UpdateChecker{
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@SubscribeEvent(receiveCanceled = true)
|
@SubscribeEvent(receiveCanceled = true)
|
||||||
public void onTick(TickEvent.ClientTickEvent event){
|
public void onTick(TickEvent.ClientTickEvent event){
|
||||||
//Don't notify directly to prevent the Message getting lost in Spam on World Joining
|
if(Minecraft.getMinecraft().player != null){
|
||||||
if(!notified && Minecraft.getMinecraft().player != null){
|
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||||
ticksElapsedBeforeInfo++;
|
if(UpdateChecker.checkFailed){
|
||||||
if(ticksElapsedBeforeInfo >= 800){
|
player.sendMessage(ITextComponent.Serializer.jsonToComponent(StringUtil.localize("info."+ActuallyAdditions.MODID+".update.failed")));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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