mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Added the new update checker for 1.8 as well
This commit is contained in:
parent
5bc747f6aa
commit
2620687e2d
5 changed files with 42 additions and 13 deletions
|
@ -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"),
|
||||
|
@ -73,4 +75,4 @@ public enum ConfigBoolValues{
|
|||
return this.currentValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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()){
|
||||
|
@ -28,4 +29,4 @@ public class UpdateChecker{
|
|||
new ThreadUpdateChecker();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.)
|
2
update/updateVersions.properties
Normal file
2
update/updateVersions.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
1.7.10=21
|
||||
1.8.9=22
|
Loading…
Reference in a new issue