Added the new update checker for 1.8 as well

This commit is contained in:
Ellpeck 2016-01-10 20:59:13 +01:00
parent 5bc747f6aa
commit 2620687e2d
5 changed files with 42 additions and 13 deletions

View file

@ -23,6 +23,8 @@ public enum ConfigBoolValues{
GENERATE_QUARTZ("Black Quartz", ConfigCategories.WORLD_GEN, true, "If the Black Quartz generates in the world"),
DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If Actually Additions should check for an Update on joining a World"),
UPDATE_CHECK_VERSION_SPECIFIC("Version Specific Update Checker", ConfigCategories.OTHER, false, "If Actually Additions' Update Check should only search for updates for the Minecraft Version you currently have"),
DO_CAT_DROPS("Do Cat Drops", ConfigCategories.OTHER, true, "If Cats drop Hairy Balls on Occasion"),
TF_PAXELS("Thermal Foundation Paxels", ConfigCategories.OTHER, true, "If Paxels made of Thermal Foundation Materials should exist"),

View file

@ -10,11 +10,12 @@
package de.ellpeck.actuallyadditions.mod.update;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Properties;
public class ThreadUpdateChecker extends Thread{
@ -28,14 +29,36 @@ public class ThreadUpdateChecker extends Thread{
public void run(){
ModUtil.LOGGER.info("Starting Update Check...");
try{
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/updateVersion.txt");
BufferedReader newestReader = new BufferedReader(new InputStreamReader(newestURL.openStream()));
UpdateChecker.updateVersion = newestReader.readLine();
newestReader.close();
URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/updateVersions.properties");
Properties updateProperties = new Properties();
updateProperties.load(new InputStreamReader(newestURL.openStream()));
int updateVersion = Integer.parseInt(UpdateChecker.updateVersion.replace("-", "").replace(".", "").replace("r", ""));
int clientVersion = Integer.parseInt(ModUtil.VERSION.replace("-", "").replace(".", "").replace("r", ""));
if(updateVersion > clientVersion){
String currentMcVersion = ModUtil.VERSION.split("-")[0];
if(ConfigBoolValues.UPDATE_CHECK_VERSION_SPECIFIC.isEnabled()){
String newestVersionProp = updateProperties.getProperty(currentMcVersion);
UpdateChecker.updateVersionInt = Integer.parseInt(newestVersionProp);
UpdateChecker.updateVersionString = currentMcVersion+"-r"+newestVersionProp;
}
else{
int highest = 0;
String highestString = "";
for(String updateMC : updateProperties.stringPropertyNames()){
String updateVersion = updateProperties.getProperty(updateMC);
int update = Integer.parseInt(updateVersion);
if(highest < update){
highest = update;
highestString = updateMC+"-r"+updateVersion;
}
}
UpdateChecker.updateVersionInt = highest;
UpdateChecker.updateVersionString = highestString;
}
int clientVersion = Integer.parseInt(ModUtil.VERSION.substring(ModUtil.VERSION.indexOf("r")+1));
if(UpdateChecker.updateVersionInt > clientVersion){
UpdateChecker.needsUpdateNotify = true;
}
@ -49,7 +72,7 @@ public class ThreadUpdateChecker extends Thread{
if(!UpdateChecker.checkFailed){
if(UpdateChecker.needsUpdateNotify){
ModUtil.LOGGER.info("There is an Update for "+ModUtil.NAME+" available!");
ModUtil.LOGGER.info("Current Version: "+ModUtil.VERSION+", newest Version: "+UpdateChecker.updateVersion+"!");
ModUtil.LOGGER.info("Current Version: "+ModUtil.VERSION+", newest Version: "+UpdateChecker.updateVersionString+"!");
ModUtil.LOGGER.info("View the Changelog at "+UpdateChecker.CHANGELOG_LINK);
ModUtil.LOGGER.info("Download at "+UpdateChecker.DOWNLOAD_LINK);
}

View file

@ -20,7 +20,8 @@ public class UpdateChecker{
public static final String CHANGELOG_LINK = "http://ellpeck.de/actaddchangelog/";
public static boolean checkFailed;
public static boolean needsUpdateNotify;
public static String updateVersion;
public static int updateVersionInt;
public static String updateVersionString;
public static void init(){
if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled() && !Util.isDevVersion()){

View file

@ -1 +1,2 @@
1.7.10-r20
1.7.10-r21
(This is a fallback for old versions which don't have the new update checker. Don't change.)

View file

@ -0,0 +1,2 @@
1.7.10=21
1.8.9=22