mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 19:59:55 +00:00
Update preloader to 0.1.1
Restore AT function (went missing in a merge), add verbose log toggle, reinforce PropertyManager.
This commit is contained in:
1 parent
ec005e14ad
commit
7c68cfbcc5
3 files changed
+91
-35
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package tconstruct.preloader;
|
||||
|
||||
import cpw.mods.fml.common.asm.transformers.AccessTransformer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class AccessTransformers extends AccessTransformer {
|
||||
|
||||
public AccessTransformers() throws IOException {
|
||||
super();
|
||||
|
||||
readMapFile("TConstruct_at.cfg");
|
||||
}
|
||||
|
||||
private void readMapFile(String name) {
|
||||
TConstructLoaderContainer.logger.info("[AT] Loading AT file: " + name);
|
||||
try {
|
||||
Method me = AccessTransformer.class.getDeclaredMethod("readMapFile", new Class[]{String.class});
|
||||
me.setAccessible(true);
|
||||
me.invoke(this, name);
|
||||
} catch (Exception ex) {
|
||||
TConstructLoaderContainer.logger.severe("[AT] Unknown failure occured: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,15 +20,16 @@ import tconstruct.preloader.helpers.PropertyManager.PropAccessException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TConstructLoaderContainer extends DummyModContainer implements IFMLLoadingPlugin
|
||||
{
|
||||
|
||||
private final String[] asmTransformers = new String[] { "tconstruct.preloader.ASMInterfaceRepair" };
|
||||
private final String[] asmTransformers = new String[] { "tconstruct.preloader.ASMInterfaceRepair", "tconstruct.preloader.AccessTransformers" };
|
||||
private final ModMetadata md = new ModMetadata();
|
||||
|
||||
public static Logger logger = Logger.getLogger("TCon-Preloader");
|
||||
public static Logger logger = Logger.getLogger("TCorestruct");
|
||||
|
||||
public TConstructLoaderContainer()
|
||||
{
|
||||
@@ -45,22 +46,30 @@ public class TConstructLoaderContainer extends DummyModContainer implements IFML
|
||||
logger.severe(Arrays.toString(ex.getStackTrace()));
|
||||
}
|
||||
|
||||
if (PropertyManager.preloaderContainer_verboseLog)
|
||||
{
|
||||
// Log ALL the things.
|
||||
logger.warning("The preloader will now log absolutely everything. To disable this, either change preloaderContainer_verboseLog");
|
||||
logger.warning("in (or delete the config file) '" + PropertyManager.propFileName + "'.");
|
||||
logger.setLevel(Level.ALL);
|
||||
}
|
||||
|
||||
if (PropertyManager.asmInterfaceRepair_verboseLog)
|
||||
{
|
||||
logger.warning("ASM Interface Repair is set to be verbose, this is NOT GOOD FOR SERVERS, as it will spam the logs!");
|
||||
logger.warning("The debug mode is for debug use only. Turn it off unless instructed otherwise by a TCon developer!");
|
||||
logger.warning("The debug mode is for debug use only. Turn it off unless instructed otherwise by a TCon developer.");
|
||||
logger.warning("To reset advanced settings to default, delete the '" + PropertyManager.propFileName + "' file from the config folder.");
|
||||
}
|
||||
|
||||
md.autogenerated = true;
|
||||
md.credits = "AlgorithmX2 (original) and Sunstrike (porting)";
|
||||
md.credits = "AlgorithmX2 and Sunstrike";
|
||||
md.modId = getModId();
|
||||
md.version = getVersion();
|
||||
md.name = getName();
|
||||
md.authorList = Arrays.asList("AlgorithmX2", "Sunstrike");
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
/*@ForgeSubscribe
|
||||
public void preInit (FMLPreInitializationEvent evt)
|
||||
{
|
||||
|
||||
@@ -76,7 +85,7 @@ public class TConstructLoaderContainer extends DummyModContainer implements IFML
|
||||
public void postInit (FMLPostInitializationEvent evt)
|
||||
{
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String getModId ()
|
||||
@@ -93,7 +102,7 @@ public class TConstructLoaderContainer extends DummyModContainer implements IFML
|
||||
@Override
|
||||
public String getVersion ()
|
||||
{
|
||||
return "0.0.1";
|
||||
return "0.1.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,12 +124,6 @@ public class TConstructLoaderContainer extends DummyModContainer implements IFML
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String[] getLibraryRequestClass ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass ()
|
||||
{
|
||||
|
||||
@@ -6,6 +6,9 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@@ -24,6 +27,8 @@ public class PropertyManager
|
||||
|
||||
public static final String propFileName = "TConPreloader.cfg";
|
||||
|
||||
private static String[] vars = new String[]{"preloaderContainer_verboseLog", "asmInterfaceRepair_verboseLog"};
|
||||
public static boolean preloaderContainer_verboseLog = false;
|
||||
public static boolean asmInterfaceRepair_verboseLog = false;
|
||||
|
||||
/**
|
||||
@@ -44,6 +49,13 @@ public class PropertyManager
|
||||
TConstructLoaderContainer.logger.info("Found a properties file. Attempting load...");
|
||||
props.load(new FileInputStream(fp));
|
||||
|
||||
for (String var : vars)
|
||||
{
|
||||
if (!props.containsKey(var))
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
preloaderContainer_verboseLog = props.getProperty("preloaderContainer_verboseLog", "false").equalsIgnoreCase("true");
|
||||
asmInterfaceRepair_verboseLog = props.getProperty("asmInterfaceRepair_verboseLog", "false").equalsIgnoreCase("true");
|
||||
|
||||
TConstructLoaderContainer.logger.info("Loaded properties successfully. Using specified settings.");
|
||||
@@ -52,36 +64,49 @@ public class PropertyManager
|
||||
{
|
||||
throw new PropAccessException();
|
||||
}
|
||||
catch (NullPointerException ex) {
|
||||
TConstructLoaderContainer.logger.warning("Preloader config structure has changed; attempting to recreate.");
|
||||
attemptCreate(fp, props);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Attempt creation
|
||||
try
|
||||
{
|
||||
if (fp.createNewFile())
|
||||
{
|
||||
TConstructLoaderContainer.logger.info("Creating new properties file, as none found...");
|
||||
|
||||
props.setProperty("asmInterfaceRepair_verboseLog", "false");
|
||||
|
||||
props.store(new FileOutputStream(fp), null);
|
||||
TConstructLoaderContainer.logger.info("Created properties file; using defaults this run.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PropAccessException();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw new PropAccessException();
|
||||
}
|
||||
TConstructLoaderContainer.logger.info("Preloader config not found. Attempting to make a new one.");
|
||||
attemptCreate(fp, props);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void attemptCreate(File fp, Properties props) throws PropAccessException {
|
||||
// Attempt (re)creation
|
||||
try
|
||||
{
|
||||
if (fp.exists())
|
||||
fp.delete();
|
||||
|
||||
if (fp.createNewFile())
|
||||
{
|
||||
TConstructLoaderContainer.logger.info("Creating new properties file, as none found...");
|
||||
|
||||
props.setProperty("asmInterfaceRepair_verboseLog", "false");
|
||||
props.setProperty("preloaderContainer_verboseLog", "false");
|
||||
|
||||
props.store(new FileOutputStream(fp), null);
|
||||
TConstructLoaderContainer.logger.info("Created properties file; using defaults this run.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PropAccessException();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
throw new PropAccessException();
|
||||
}
|
||||
}
|
||||
|
||||
public static class PropAccessException extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user