Simple log helper class, cleaned up some logging, and added listing for a Dutch translation file of EE3 (incoming PR merge)
This commit is contained in:
parent
d2c456b76f
commit
289de4abfd
|
@ -3,6 +3,7 @@ package ee3.client.core.handlers;
|
|||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import ee3.common.core.helper.LogHelper;
|
||||
import ee3.common.lib.Reference;
|
||||
import ee3.common.lib.Sounds;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
|
@ -31,7 +32,7 @@ public class SoundHandler {
|
|||
// If we cannot add the custom sound file to the pool, log the
|
||||
// exception
|
||||
catch (Exception e) {
|
||||
FMLCommonHandler.instance().getFMLLogger().log(Level.WARNING, Reference.LOGGER_PREFIX + "Failed loading sound file: " + soundFile);
|
||||
LogHelper.log(Level.WARNING, "Failed loading sound file: " + soundFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,12 @@ public class EquivalentExchange3 {
|
|||
// Initialize the configuration
|
||||
ConfigurationHandler.init(event.getSuggestedConfigurationFile());
|
||||
|
||||
// Conduct the version check
|
||||
// Load the localization files into the LanguageRegistry
|
||||
LocalizationHandler.loadLanguages();
|
||||
|
||||
// Conduct the version check and log the result
|
||||
VersionHelper.checkVersion();
|
||||
VersionHelper.logResult();
|
||||
|
||||
// Initialize the Version Check Tick Handler (Client only)
|
||||
TickRegistry.registerTickHandler(new VersionCheckTickHandler(), Side.CLIENT);
|
||||
|
@ -73,9 +77,6 @@ public class EquivalentExchange3 {
|
|||
@Init
|
||||
public void load(FMLInitializationEvent event) {
|
||||
|
||||
// Load the localization files into the LanguageRegistry
|
||||
LocalizationHandler.loadLanguages();
|
||||
|
||||
// Initialize the custom item rarity types
|
||||
proxy.initCustomRarityTypes();
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ public class LocalizationHandler {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
} finally {
|
||||
// Close the input stream when we are done with it
|
||||
try {
|
||||
if (languageStream != null) {
|
||||
languageStream.close();
|
||||
|
|
15
ee3_common/ee3/common/core/helper/LogHelper.java
Normal file
15
ee3_common/ee3/common/core/helper/LogHelper.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package ee3.common.core.helper;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import ee3.common.lib.Reference;
|
||||
|
||||
public class LogHelper {
|
||||
|
||||
public static void log(Level logLevel, String message) {
|
||||
System.out.println(Reference.LOGGER_PREFIX + message);
|
||||
FMLCommonHandler.instance().getFMLLogger().log(logLevel, Reference.LOGGER_PREFIX + message);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package ee3.common.core.helper;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
@ -28,6 +29,12 @@ public class VersionHelper {
|
|||
public static final byte CURRENT = 1;
|
||||
public static final byte OUTDATED = 2;
|
||||
public static final byte CONNECTION_ERROR = 3;
|
||||
|
||||
// Localization keys
|
||||
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
|
||||
public static byte result = UNINITIALIZED;
|
||||
|
@ -73,33 +80,33 @@ public class VersionHelper {
|
|||
isr.close();
|
||||
} catch (Exception e) {
|
||||
// If we cannot connect to the remote version number authority, set the version check appropriately
|
||||
e.printStackTrace(System.err);
|
||||
result = CONNECTION_ERROR;
|
||||
}
|
||||
|
||||
logResult();
|
||||
}
|
||||
|
||||
public static void logResult() {
|
||||
if ((result == CURRENT) || (result == OUTDATED)) {
|
||||
FMLCommonHandler.instance().getFMLLogger().fine(getResultMessage());
|
||||
LogHelper.log(Level.FINE, getResultMessage());
|
||||
}
|
||||
else {
|
||||
FMLCommonHandler.instance().getFMLLogger().warning(getResultMessage());
|
||||
LogHelper.log(Level.WARNING, getResultMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getResultMessage() {
|
||||
if (result == UNINITIALIZED) {
|
||||
return "Uninitialized";
|
||||
return LocalizationHelper.localize(UNINITIALIZED_MESSAGE);
|
||||
}
|
||||
else if (result == CURRENT) {
|
||||
return "Current";
|
||||
return LocalizationHelper.localize(CURRENT_MESSAGE);
|
||||
}
|
||||
else if (result == OUTDATED) {
|
||||
return "Outdated";
|
||||
return LocalizationHelper.localize(OUTDATED_MESSAGE);
|
||||
}
|
||||
else if (result == CONNECTION_ERROR) {
|
||||
return "Connection Error";
|
||||
return LocalizationHelper.localize(CONNECTION_ERROR_MESSAGE);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
|
|
@ -14,7 +14,8 @@ public class Localizations {
|
|||
private static final String LANG_RESOURCE_LOCATION = "/ee3/lang/";
|
||||
|
||||
public static String[] localeFiles = {
|
||||
LANG_RESOURCE_LOCATION + "en_US.xml"
|
||||
LANG_RESOURCE_LOCATION + "en_US.xml",
|
||||
LANG_RESOURCE_LOCATION + "nl_NL.xml",
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue