Updated Update Checker

This commit is contained in:
Ellpeck 2015-10-13 02:12:30 +02:00
parent 1dbe79ac6f
commit c5f11fb380
2 changed files with 22 additions and 24 deletions

View file

@ -153,12 +153,18 @@ public class GuiBooklet extends GuiScreen{
} }
//Update Checker Hover Text //Update Checker Hover Text
if(x >= this.guiLeft-11 && x <= this.guiLeft-11+10 && y >= this.guiTop-11 && y <= this.guiTop-11+10){ if(x >= this.guiLeft-11 && x <= this.guiLeft-11+10 && y >= this.guiTop-11 && y <= this.guiTop-11+10){
if(UpdateChecker.doneChecking && UpdateChecker.updateVersion > UpdateChecker.clientVersion){ if(UpdateChecker.doneChecking){
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(EnumChatFormatting.GOLD+"There is an Update available!"); if(UpdateChecker.checkFailed){
list.add(EnumChatFormatting.ITALIC+"You have: "+ModUtil.VERSION+", Newest: "+UpdateChecker.updateVersionS); list.add(EnumChatFormatting.DARK_RED+"The Update Check failed!");
list.addAll(this.fontRendererObj.listFormattedStringToWidth(EnumChatFormatting.ITALIC+"Updates include: "+UpdateChecker.changelog, TOOLTIP_SPLIT_LENGTH)); list.add("Check your log for more Information!");
list.add(EnumChatFormatting.GRAY+"Click this button to visit the download page!"); }
else if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
list.add(EnumChatFormatting.GOLD+"There is an Update available!");
list.add(EnumChatFormatting.ITALIC+"You have: "+ModUtil.VERSION+", Newest: "+UpdateChecker.updateVersionS);
list.addAll(this.fontRendererObj.listFormattedStringToWidth(EnumChatFormatting.ITALIC+"Updates include: "+UpdateChecker.changelog, TOOLTIP_SPLIT_LENGTH));
list.add(EnumChatFormatting.GRAY+"Click this button to visit the download page!");
}
this.func_146283_a(list, x, y); this.func_146283_a(list, x, y);
} }
} }

View file

@ -39,6 +39,9 @@ public class ThreadUpdateChecker extends Thread{
changeReader.close(); changeReader.close();
ModUtil.LOGGER.info("Update Check done!"); ModUtil.LOGGER.info("Update Check done!");
UpdateChecker.updateVersion = Integer.parseInt(UpdateChecker.updateVersionS.replace("-", "").replace(".", ""));
UpdateChecker.clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", ""));
} }
catch(Exception e){ catch(Exception e){
ModUtil.LOGGER.error("Update Check failed!", e); ModUtil.LOGGER.error("Update Check failed!", e);
@ -46,26 +49,15 @@ public class ThreadUpdateChecker extends Thread{
} }
if(!UpdateChecker.checkFailed){ if(!UpdateChecker.checkFailed){
try{ if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
UpdateChecker.updateVersion = Integer.parseInt(UpdateChecker.updateVersionS.replace("-", "").replace(".", "")); ModUtil.LOGGER.info("There is an Update for "+ModUtil.MOD_ID+" available!");
UpdateChecker.clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", "")); ModUtil.LOGGER.info("The installed Version is "+ModUtil.VERSION+", but the newest Version is "+UpdateChecker.updateVersionS+"!");
ModUtil.LOGGER.info("The Changes are: "+UpdateChecker.changelog);
ModUtil.LOGGER.info("Download the newest Version at "+UpdateChecker.DOWNLOAD_LINK);
} }
catch(Exception e){ else{
ModUtil.LOGGER.error("Comparing the newest and the current Version failed!", e); ModUtil.LOGGER.info("There is no new Update for "+ModUtil.MOD_ID+" available!");
UpdateChecker.checkFailed = true; ModUtil.LOGGER.info("That's cool. You're really up to date, you have all of the latest awesome Features!");
}
if(!UpdateChecker.checkFailed){
if(UpdateChecker.updateVersion > UpdateChecker.clientVersion){
ModUtil.LOGGER.info("There is an Update for "+ModUtil.MOD_ID+" available!");
ModUtil.LOGGER.info("The installed Version is "+ModUtil.VERSION+", but the newest Version is "+UpdateChecker.updateVersionS+"!");
ModUtil.LOGGER.info("The Changes are: "+UpdateChecker.changelog);
ModUtil.LOGGER.info("Download the newest Version at "+UpdateChecker.DOWNLOAD_LINK);
}
else{
ModUtil.LOGGER.info("There is no new Update for "+ModUtil.MOD_ID+" available!");
ModUtil.LOGGER.info("That's cool. You're really up to date, you have all of the latest awesome Features!");
}
} }
} }