Made Update Checker not break when using an unstable build

This commit is contained in:
Ellpeck 2016-08-01 16:29:35 +02:00
parent 116dc6d174
commit 01853ae9af
3 changed files with 16 additions and 3 deletions

View file

@ -107,7 +107,7 @@ public final class BookletUtils{
version = "Dev's Edition";
}
else{
version = StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.edition")+" "+ModUtil.VERSION.substring(ModUtil.VERSION.indexOf("r")+1);
version = StringUtil.localize("info."+ModUtil.MOD_ID+".booklet.edition")+" "+Util.getMajorModVersion();
}
strg = TextFormatting.GOLD+TextFormatting.ITALIC.toString()+"-"+version+"-";
booklet.getFontRenderer().drawString(strg, booklet.guiLeft+booklet.xSize/2-booklet.getFontRenderer().getStringWidth(strg)/2-3, booklet.guiTop+33, 0);

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import java.io.InputStreamReader;
import java.net.URL;
@ -33,7 +34,7 @@ public class ThreadUpdateChecker extends Thread{
Properties updateProperties = new Properties();
updateProperties.load(new InputStreamReader(newestURL.openStream()));
String currentMcVersion = ModUtil.VERSION.split("-")[0];
String currentMcVersion = Util.getMcVersion();
if(ConfigBoolValues.UPDATE_CHECK_VERSION_SPECIFIC.isEnabled()){
String newestVersionProp = updateProperties.getProperty(currentMcVersion);
@ -57,7 +58,7 @@ public class ThreadUpdateChecker extends Thread{
UpdateChecker.updateVersionString = highestString;
}
String clientVersionString = ModUtil.VERSION.substring(ModUtil.VERSION.indexOf("r")+1);
String clientVersionString = Util.getMajorModVersion();
int clientVersion = Integer.parseInt(clientVersionString.contains("_") ? clientVersionString.substring(0, clientVersionString.indexOf("_")) : clientVersionString);
if(UpdateChecker.updateVersionInt > clientVersion){
UpdateChecker.needsUpdateNotify = true;

View file

@ -41,4 +41,16 @@ public final class Util{
public static boolean isDevVersion(){
return ModUtil.VERSION.equals("@VERSION@");
}
private static String[] splitVersion(){
return ModUtil.VERSION.split("-");
}
public static String getMcVersion(){
return splitVersion()[0];
}
public static String getMajorModVersion(){
return splitVersion()[1].substring(1);
}
}