Config options to enable/disable the version check, updated lang (en_US) with final version check text, reports in the log where it is checking the version number

This commit is contained in:
pahimar 2012-10-11 13:23:21 -04:00
parent 9d69168a5e
commit 4f188ca935
7 changed files with 61 additions and 28 deletions

View file

@ -29,6 +29,7 @@ import ee3.common.core.handlers.PlayerDestroyItemHandler;
import ee3.common.core.handlers.VersionCheckTickHandler;
import ee3.common.core.helper.VersionHelper;
import ee3.common.item.ModItems;
import ee3.common.lib.ConfigurationSettings;
import ee3.common.lib.Reference;
import ee3.common.recipe.RecipesTransmutationStone;
@ -61,8 +62,10 @@ public class EquivalentExchange3 {
ConfigurationHandler.init(event.getSuggestedConfigurationFile());
// Conduct the version check and log the result
VersionHelper.checkVersion();
VersionHelper.logResult();
if (ConfigurationSettings.ENABLE_VERSION_CHECK) {
VersionHelper.checkVersion();
}
VersionHelper.logResult();
// Initialize the Version Check Tick Handler (Client only)
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);

View file

@ -33,6 +33,9 @@ public class ConfigurationHandler {
configuration.load();
/* General Configs */
ConfigurationSettings.ENABLE_VERSION_CHECK = configuration
.get(CATEGORY_GENERAL, Reference.ENABLE_VERSION_CHECK, ConfigurationSettings.ENABLE_VERSION_CHECK_DEFAULT)
.getBoolean(ConfigurationSettings.ENABLE_VERSION_CHECK_DEFAULT);
ConfigurationSettings.ENABLE_SOUNDS = configuration
.get(CATEGORY_GENERAL, Reference.ENABLE_SOUNDS, ConfigurationSettings.ENABLE_SOUNDS_DEFAULT)
.getBoolean(ConfigurationSettings.ENABLE_SOUNDS_DEFAULT);

View file

@ -6,6 +6,7 @@ import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
import ee3.common.core.helper.VersionHelper;
import ee3.common.lib.ConfigurationSettings;
import ee3.common.lib.Reference;
public class VersionCheckTickHandler implements ITickHandler {
@ -17,12 +18,14 @@ public class VersionCheckTickHandler implements ITickHandler {
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
if (!initialized) {
for (TickType tickType : type) {
if (tickType == TickType.CLIENT) {
if (FMLClientHandler.instance().getClient().currentScreen == null) {
initialized = true;
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(VersionHelper.getResultMessage());
if (ConfigurationSettings.ENABLE_VERSION_CHECK) {
if (!initialized) {
for (TickType tickType : type) {
if (tickType == TickType.CLIENT) {
if (FMLClientHandler.instance().getClient().currentScreen == null) {
initialized = true;
FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(Reference.VERSION_CHECK_COLOUR_PREFIX + VersionHelper.getResultMessage());
}
}
}
}

View file

@ -8,6 +8,7 @@ import java.util.logging.Level;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ee3.common.lib.ConfigurationSettings;
import ee3.common.lib.Reference;
/**
@ -32,12 +33,14 @@ public class VersionHelper {
public static final byte CONNECTION_ERROR = 3;
// Localization keys
private static final String VERSION_CHECK_DISABLED = "version.check_disabled";
private static final String VERSION_CHECK_INIT_LOG_MESSAGE = "version.init_log_message";
private static final String UNINITIALIZED_MESSAGE = "version.uninitialized";
private static final String CURRENT_MESSAGE = "version.current";
private static final String OUTDATED_MESSAGE = "version.outdated";
private static final String CONNECTION_ERROR_MESSAGE = "version.connection_error";
// Var to hold the result of the remote version check
// Var to hold the result of the remote version check, initially set to uninitialized
public static byte result = UNINITIALIZED;
/***
@ -88,29 +91,40 @@ public class VersionHelper {
}
public static void logResult() {
if ((result == CURRENT) || (result == OUTDATED)) {
LogHelper.log(Level.FINE, getResultMessage());
if (ConfigurationSettings.ENABLE_VERSION_CHECK) {
LogHelper.log(Level.FINE, LanguageRegistry.instance().getStringLocalization(VERSION_CHECK_INIT_LOG_MESSAGE) + " " + REMOTE_VERSION_FILE);
if ((result == CURRENT) || (result == OUTDATED)) {
LogHelper.log(Level.FINE, getResultMessage());
}
else {
LogHelper.log(Level.WARNING, getResultMessage());
}
}
else {
LogHelper.log(Level.WARNING, getResultMessage());
LogHelper.log(Level.FINE, getResultMessage());
}
}
public static String getResultMessage() {
if (result == UNINITIALIZED) {
return LanguageRegistry.instance().getStringLocalization(UNINITIALIZED_MESSAGE);
}
else if (result == CURRENT) {
return LanguageRegistry.instance().getStringLocalization(CURRENT_MESSAGE);
}
else if (result == OUTDATED) {
return LanguageRegistry.instance().getStringLocalization(OUTDATED_MESSAGE);
}
else if (result == CONNECTION_ERROR) {
return LanguageRegistry.instance().getStringLocalization(CONNECTION_ERROR_MESSAGE);
if (ConfigurationSettings.ENABLE_VERSION_CHECK) {
if (result == UNINITIALIZED) {
return LanguageRegistry.instance().getStringLocalization(UNINITIALIZED_MESSAGE);
}
else if (result == CURRENT) {
return LanguageRegistry.instance().getStringLocalization(CURRENT_MESSAGE);
}
else if (result == OUTDATED) {
return LanguageRegistry.instance().getStringLocalization(OUTDATED_MESSAGE);
}
else if (result == CONNECTION_ERROR) {
return LanguageRegistry.instance().getStringLocalization(CONNECTION_ERROR_MESSAGE);
}
else {
return null;
}
}
else {
return null;
return LanguageRegistry.instance().getStringLocalization(VERSION_CHECK_DISABLED);
}
}

View file

@ -19,6 +19,10 @@ public class ConfigurationSettings {
public static boolean ENABLE_PARTICLE_FX;
public static final boolean ENABLE_PARTICLE_FX_DEFAULT = true;
// Whether or not EE3 will do a version check when loaded
public static boolean ENABLE_VERSION_CHECK;
public static final boolean ENABLE_VERSION_CHECK_DEFAULT = true;
/*
* Minium stone config settings
*/

View file

@ -24,10 +24,14 @@ public class Reference {
public static final int SHIFTED_ID_RANGE_CORRECTION = 256;
/* Configuration related constants */
public static final String ENABLE_VERSION_CHECK = "enable_version_check";
public static final String ENABLE_SOUNDS = "enable_sounds";
public static final String ENABLE_PARTICLE_FX = "enable_particle_fx";
public static final String AUTO_RESOLVE_BLOCK_IDS = "auto_resolve_block_ids";
/* Text colour related constants */
public static final String VERSION_CHECK_COLOUR_PREFIX = "\u00a7e";
/* KeyBinding related constants */
// TODO: Localize keybinding names
public static final String KEYBINDING_EXTRA = "mod.ee3.extra_key";

View file

@ -8,8 +8,10 @@
<entry key="tile.redWaterStill.name">Red Water (Still)</entry>
<entry key="tile.redWaterFlowing.name">Red Water (Flowing)</entry>
<entry key="tile.calcinator.name">Calcinator</entry>
<entry key="version.uninitialized">Uninitialized</entry>
<entry key="version.current">Current</entry>
<entry key="version.outdated">Outdated</entry>
<entry key="version.connection_error">Connection Error</entry>
<entry key="version.init_log_message">Initializing version check for Equivalent Exchange against the remote version authority file, located at</entry>
<entry key="version.uninitialized">The version check for Equivalent Exchange did not complete successfully (version check did not initialize properly)</entry>
<entry key="version.current">You are currently using the most up to date version of Equivalent Exchange for your version of Minecraft (yay!)</entry>
<entry key="version.outdated">You are currently using an out of date version of Equivalent Exchange; consider updating here - http://goo.gl/sNcGl</entry>
<entry key="version.connection_error">Error connecting to the remote Equivalent Exchange version authority file (check your Internet connection?)</entry>
<entry key="version.check_disabled">Remote version check for Equivalent Exchange disabled</entry>
</properties>