Testing some new Version Check mechanics

This commit is contained in:
pahimar 2013-03-19 10:42:28 -04:00
parent 4cd352c7dc
commit f0ac7a41fc
6 changed files with 65 additions and 17 deletions

View file

@ -46,6 +46,7 @@ public class ConfigurationHandler {
/* General configs */
ConfigurationSettings.DISPLAY_VERSION_RESULT = configuration.get(CATEGORY_GENERAL, ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME, ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT).getBoolean(ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT);
ConfigurationSettings.LAST_DISCOVERED_VERSION = configuration.get(CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_DEFAULT).getString();
ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE = configuration.get(CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_DEFAULT).getString();
/* Graphic configs */
ConfigurationSettings.ENABLE_PARTICLE_FX = configuration.get(CATEGORY_GRAPHICS, ConfigurationSettings.ENABLE_PARTICLE_FX_CONFIGNAME, ConfigurationSettings.ENABLE_PARTICLE_FX_DEFAULT).getBoolean(ConfigurationSettings.ENABLE_PARTICLE_FX_DEFAULT);

View file

@ -14,9 +14,8 @@ import com.pahimar.ee3.lib.Strings;
public class ConfigurationSettings {
/*
* General configuration settings
* Version check related settings
*/
// Whether or not EE3 will do a version check when loaded
public static boolean DISPLAY_VERSION_RESULT;
public static final String DISPLAY_VERSION_RESULT_CONFIGNAME = "version_check.display_results";
public static final boolean DISPLAY_VERSION_RESULT_DEFAULT = true;
@ -24,6 +23,10 @@ public class ConfigurationSettings {
public static String LAST_DISCOVERED_VERSION;
public static final String LAST_DISCOVERED_VERSION_CONFIGNAME = "version_check.last_discovered_version";
public static final String LAST_DISCOVERED_VERSION_DEFAULT = "";
public static String LAST_DISCOVERED_VERSION_TYPE;
public static final String LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME = "version_check.last_discovered_version_type";
public static final String LAST_DISCOVERED_VERSION_TYPE_DEFAULT = "";
/*
* Audio config settings

View file

@ -46,6 +46,7 @@ public class VersionHelper implements Runnable {
private static byte result = UNINITIALIZED;
public static String remoteVersion = null;
public static String remoteUpdateLocation = null;
public static String remoteVersionType = null;
/***
* Checks the version of the currently running instance of the mod against
@ -65,27 +66,67 @@ public class VersionHelper implements Runnable {
String remoteVersionProperty = remoteVersionProperties.getProperty(Loader.instance().getMCVersionString());
if (remoteVersionProperty != null) {
remoteVersion = remoteVersionProperty.substring(0, remoteVersionProperty.indexOf("|"));
remoteUpdateLocation = remoteVersionProperty.substring(remoteVersionProperty.indexOf("|") + 1);
}
String[] remoteVersionTokens = remoteVersionProperty.split("|");
if (remoteVersion != null) {
if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion)) {
ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, remoteVersion);
if (remoteVersionTokens.length == 2) {
remoteVersion = remoteVersionTokens[0];
remoteUpdateLocation = remoteVersionTokens[1];
}
else if (remoteVersionTokens.length == 3) {
remoteVersion = remoteVersionTokens[0];
remoteUpdateLocation = remoteVersionTokens[1];
remoteVersionType = remoteVersionTokens[2];
}
else {
result = ERROR;
return;
}
if (remoteVersion.equals(Reference.VERSION)) {
result = CURRENT;
if (remoteVersion != null) {
if (!ConfigurationSettings.LAST_DISCOVERED_VERSION.equalsIgnoreCase(remoteVersion)) {
ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME, remoteVersion);
if (remoteVersionType != null) {
ConfigurationHandler.set(Configuration.CATEGORY_GENERAL, ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME, remoteVersionType);
}
}
if (remoteVersion.equalsIgnoreCase(Reference.VERSION)) {
if (remoteVersionType != null) {
if (remoteVersionType.equalsIgnoreCase(Reference.VERSION_TYPE) && remoteVersionType.equalsIgnoreCase(Strings.RECOMMENDED_VERSION)) {
result = CURRENT;
return;
}
}
else {
result = CURRENT;
return;
}
}
else {
result = OUTDATED;
return;
}
}
else {
result = ERROR;
return;
}
}
if (remoteVersionProperty == null) {
else {
result = MC_VERSION_NOT_FOUND;
}
else {
result = OUTDATED;
}
/*
* if (remoteVersion != null) { if
* (!ConfigurationSettings.LAST_DISCOVERED_VERSION
* .equalsIgnoreCase(remoteVersion)) {
* ConfigurationHandler.set(Configuration.CATEGORY_GENERAL,
* ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME,
* remoteVersion); } if (remoteVersion.equals(Reference.VERSION)) {
* result = CURRENT; return; } } if (remoteVersionProperty == null)
* { result = MC_VERSION_NOT_FOUND; } else { result = OUTDATED; }
*/
}
catch (Exception e) {
}

View file

@ -18,6 +18,7 @@ public class Reference {
public static final String MOD_ID = "EE3";
public static final String MOD_NAME = "Equivalent Exchange 3";
public static final String VERSION = "@VERSION@";
public static final String VERSION_TYPE = "@VERSION_TYPE@";
public static final String CHANNEL_NAME = MOD_ID;
public static final int SECOND_IN_TICKS = 20;
public static final int SHIFTED_ID_RANGE_CORRECTION = 256;

View file

@ -23,6 +23,8 @@ public class Strings {
public static final String GENERAL_ERROR_MESSAGE = "version.general_error";
public static final String FINAL_ERROR_MESSAGE = "version.final_error";
public static final String MC_VERSION_NOT_FOUND = "version.mc_version_not_found";
public static final String DEVELOPMENT_VERSION = "Development";
public static final String RECOMMENDED_VERSION = "Recommended";
/* NBT related constants */
public static final String NBT_ITEM_CHARGE_LEVEL_KEY = "itemChargeLevel";

View file

@ -14,13 +14,13 @@
<entry key="item.dustAlchemicalMinium.name">Mönjäinen pöly</entry>
<entry key="item.dustAlchemicalVerdant.name">Vehreä pöly</entry>
<entry key="item.dustAlchemicalAzure.name">Taivaansininen pöly</entry>
<entry key="item.dustAlchemicalAmaranthine.name">Ikikukkaispöly</entry><
<entry key="item.dustAlchemicalAmaranthine.name">Ikikukkaispöly</entry>
<entry key="item.dustAlchemicalIridescent.name">Sateenkaarenkirjava pöly</entry>
<entry key="item.alchemicalBag.name">Alkeminen pussi</entry>
<entry key="tile.redWaterStill.name">Punavesi (Liikkumaton)</entry>
<entry key="tile.redWaterFlowing.name">Punavesi (Virtaava)</entry>
<entry key="tile.calcinator.name">Kalsinaattori</entry>
<entry key="tile.aludel.name">Aludeli</entry> <comment>This needs better translation!</comment>
<entry key="tile.aludel.name">Aludeli</entry>
<entry key="tile.alchemicalChest.name">Alchemical Chest</entry>
<entry key="container.calcinator">Calcinator</entry>
<entry key="container.aludel">Aludel</entry>