make the log information meaningful and simple.
This commit is contained in:
parent
57db55e280
commit
da7e58a3ef
|
@ -19,12 +19,8 @@
|
|||
package appeng.transformer;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.LoadController;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
|
@ -34,7 +30,8 @@ import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
|||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@MCVersion( "1.7.10" )
|
||||
|
@ -64,7 +61,7 @@ public final class AppEngCore extends DummyModContainer implements IFMLLoadingPl
|
|||
@Override
|
||||
public String[] getASMTransformerClass()
|
||||
{
|
||||
return new String[] { "appeng.transformer.asm.ASMIntegration", "appeng.transformer.asm.ASMApiFixer" };
|
||||
return new String[] { "appeng.transformer.asm.ASMIntegration", "appeng.transformer.asm.ApiRepairer" };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,15 +22,8 @@ package appeng.transformer.asm;
|
|||
import appeng.helpers.Reflected;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
|
@ -41,43 +34,40 @@ import java.net.URLConnection;
|
|||
* See also : https://github.com/xsun2001/Applied-Energistics-2-Unofficial/issues/1
|
||||
*/
|
||||
@Reflected
|
||||
public class ASMApiFixer implements IClassTransformer
|
||||
public class ApiRepairer implements IClassTransformer
|
||||
{
|
||||
|
||||
public ASMApiFixer()
|
||||
public ApiRepairer()
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.INFO, "ApiFixer Installed" );
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.INFO, "%s", getClass().getResource( "" ).toString() );
|
||||
FMLRelaunchLog.log( "AE2-ApiRepairer", Level.INFO, "AE2 ApiFixer Installed" );
|
||||
}
|
||||
|
||||
@Override public byte[] transform( String name, String transformedName, byte[] basicClass )
|
||||
{
|
||||
if( transformedName.startsWith( "appeng.api" ) )
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.INFO, "Fixing api class file:%s", transformedName );
|
||||
try
|
||||
{
|
||||
String clazzurl = getClass().getResource( "" ).toString();
|
||||
clazzurl = clazzurl.substring( 0, clazzurl.length() - 23 ) + transformedName.replace( '.', '/' ) + ".class";
|
||||
//23 is "appeng/transformer/asm"'s length + 1
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.INFO, "Fixing...:%s", clazzurl );
|
||||
URL url = new URL( clazzurl );
|
||||
URLConnection connection = url.openConnection();
|
||||
byte[] bytes = new byte[connection.getContentLength()];
|
||||
if( connection.getInputStream().read( bytes ) == -1 )
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.ERROR, "Cannot fix:%s", transformedName );
|
||||
FMLRelaunchLog.log( "AE2-ApiRepairer", Level.ERROR, "Failed to fix api class [%s] because the new class couldn't be read", transformedName );
|
||||
return basicClass;
|
||||
}
|
||||
else
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.INFO, "Fix success:%s", transformedName );
|
||||
FMLRelaunchLog.log( "AE2-ApiRepairer", Level.INFO, "Successfully fix api class [%s]", transformedName );
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
FMLRelaunchLog.log( "AE2-ApiFixer", Level.ERROR, "Fix failed:%s|%s", transformedName, e.getClass().getName() );
|
||||
FMLRelaunchLog.log( "AE2-ApiRepairer", Level.ERROR, "Failed to fix api class [%s] because of [%s]", transformedName, e.getClass().getName() );
|
||||
return basicClass;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue