final variables and parameters

This commit is contained in:
thatsIch
2015-09-30 14:24:40 +02:00
parent 059523f543
commit 8b3a954f73
732 changed files with 9253 additions and 9256 deletions
+46 -46
View File
@@ -71,7 +71,7 @@ public class ApiPart implements IPartHelper
public void initFMPSupport()
{
for( Class layerInterface : this.interfaces2Layer.keySet() )
for( final Class layerInterface : this.interfaces2Layer.keySet() )
{
if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.FMP ) )
{
@@ -80,7 +80,7 @@ public class ApiPart implements IPartHelper
}
}
public Class getCombinedInstance( String base )
public Class getCombinedInstance( final String base )
{
if( this.desc.isEmpty() )
{
@@ -88,13 +88,13 @@ public class ApiPart implements IPartHelper
{
return Class.forName( base );
}
catch( ClassNotFoundException e )
catch( final ClassNotFoundException e )
{
throw new IllegalStateException( e );
}
}
String description = base + ':' + Joiner.on( ";" ).skipNulls().join( this.desc.iterator() );
final String description = base + ':' + Joiner.on( ";" ).skipNulls().join( this.desc.iterator() );
if( this.tileImplementations.get( description ) != null )
{
@@ -107,7 +107,7 @@ public class ApiPart implements IPartHelper
{
Addendum = Class.forName( base ).getSimpleName();
}
catch( ClassNotFoundException e )
catch( final ClassNotFoundException e )
{
AELog.error( e );
}
@@ -117,22 +117,22 @@ public class ApiPart implements IPartHelper
{
myCLass = Class.forName( f );
}
catch( ClassNotFoundException e )
catch( final ClassNotFoundException e )
{
throw new IllegalStateException( e );
}
String path = f;
for( String name : this.desc )
for( final String name : this.desc )
{
try
{
String newPath = path + ';' + name;
final String newPath = path + ';' + name;
myCLass = this.getClassByDesc( Addendum, newPath, f, this.interfaces2Layer.get( Class.forName( name ) ) );
path = newPath;
}
catch( Throwable t )
catch( final Throwable t )
{
AELog.warning( "Error loading " + name );
AELog.error( t );
@@ -146,51 +146,51 @@ public class ApiPart implements IPartHelper
return myCLass;
}
public Class getClassByDesc( String addendum, String fullPath, String root, String next )
public Class getClassByDesc( final String addendum, final String fullPath, final String root, final String next )
{
if( this.roots.get( fullPath ) != null )
{
return this.roots.get( fullPath );
}
ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
ClassNode n = this.getReader( next );
String originalName = n.name;
final ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS );
final ClassNode n = this.getReader( next );
final String originalName = n.name;
try
{
n.name = n.name + '_' + addendum;
n.superName = Class.forName( root ).getName().replace( ".", "/" );
}
catch( Throwable t )
catch( final Throwable t )
{
AELog.error( t );
}
for( MethodNode mn : n.methods )
for( final MethodNode mn : n.methods )
{
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
final Iterator<AbstractInsnNode> i = mn.instructions.iterator();
while( i.hasNext() )
{
this.processNode( i.next(), n.superName );
}
}
DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
final DefaultPackageClassNameRemapper remapper = new DefaultPackageClassNameRemapper();
remapper.inputOutput.put( "appeng/api/parts/LayerBase", n.superName );
remapper.inputOutput.put( originalName, n.name );
n.accept( new RemappingClassAdapter( cw, remapper ) );
// n.accept( cw );
// n.accept( new TraceClassVisitor( new PrintWriter( System.out ) ) );
byte[] byteArray = cw.toByteArray();
int size = byteArray.length;
Class clazz = this.loadClass( n.name.replace( "/", "." ), byteArray );
final byte[] byteArray = cw.toByteArray();
final int size = byteArray.length;
final Class clazz = this.loadClass( n.name.replace( "/", "." ), byteArray );
try
{
Object fish = clazz.newInstance();
Class rootC = Class.forName( root );
final Object fish = clazz.newInstance();
final Class rootC = Class.forName( root );
boolean hasError = false;
@@ -226,7 +226,7 @@ public class ApiPart implements IPartHelper
AELog.info( "Layer: " + n.name + " loaded successfully - " + size + " bytes" );
}
}
catch( Throwable t )
catch( final Throwable t )
{
AELog.severe( "Layer: " + n.name + " Failed." );
AELog.error( t );
@@ -236,30 +236,30 @@ public class ApiPart implements IPartHelper
return clazz;
}
public ClassNode getReader( String name )
public ClassNode getReader( final String name )
{
String path = '/' + name.replace( ".", "/" ) + ".class";
InputStream is = this.getClass().getResourceAsStream( path );
final String path = '/' + name.replace( ".", "/" ) + ".class";
final InputStream is = this.getClass().getResourceAsStream( path );
try
{
ClassReader cr = new ClassReader( is );
final ClassReader cr = new ClassReader( is );
ClassNode cn = new ClassNode();
final ClassNode cn = new ClassNode();
cr.accept( cn, ClassReader.EXPAND_FRAMES );
return cn;
}
catch( IOException e )
catch( final IOException e )
{
throw new IllegalStateException( "Error loading " + name, e );
}
}
private void processNode( AbstractInsnNode next, String nePar )
private void processNode( final AbstractInsnNode next, final String nePar )
{
if( next instanceof MethodInsnNode )
{
MethodInsnNode min = (MethodInsnNode) next;
final MethodInsnNode min = (MethodInsnNode) next;
if( min.owner.equals( "appeng/api/parts/LayerBase" ) )
{
min.owner = nePar;
@@ -267,26 +267,26 @@ public class ApiPart implements IPartHelper
}
}
private Class loadClass( String name, byte[] b )
private Class loadClass( final String name, byte[] b )
{
// override classDefine (as it is protected) and define the class.
Class clazz = null;
try
{
ClassLoader loader = this.getClass().getClassLoader();// ClassLoader.getSystemClassLoader();
Class<ClassLoader> root = ClassLoader.class;
Class<? extends ClassLoader> cls = loader.getClass();
Method defineClassMethod = root.getDeclaredMethod( "defineClass", String.class, byte[].class, int.class, int.class );
Method runTransformersMethod = cls.getDeclaredMethod( "runTransformers", String.class, String.class, byte[].class );
final ClassLoader loader = this.getClass().getClassLoader();// ClassLoader.getSystemClassLoader();
final Class<ClassLoader> root = ClassLoader.class;
final Class<? extends ClassLoader> cls = loader.getClass();
final Method defineClassMethod = root.getDeclaredMethod( "defineClass", String.class, byte[].class, int.class, int.class );
final Method runTransformersMethod = cls.getDeclaredMethod( "runTransformers", String.class, String.class, byte[].class );
runTransformersMethod.setAccessible( true );
defineClassMethod.setAccessible( true );
try
{
Object[] argsA = { name, name, b };
final Object[] argsA = { name, name, b };
b = (byte[]) runTransformersMethod.invoke( loader, argsA );
Object[] args = { name, b, 0, b.length };
final Object[] args = { name, b, 0, b.length };
clazz = (Class) defineClassMethod.invoke( loader, args );
}
finally
@@ -295,7 +295,7 @@ public class ApiPart implements IPartHelper
defineClassMethod.setAccessible( false );
}
}
catch( Exception e )
catch( final Exception e )
{
AELog.error( e );
throw new IllegalStateException( "Unable to manage part API.", e );
@@ -304,7 +304,7 @@ public class ApiPart implements IPartHelper
}
@Override
public boolean registerNewLayer( String layer, String layerInterface )
public boolean registerNewLayer( final String layer, final String layerInterface )
{
try
{
@@ -320,7 +320,7 @@ public class ApiPart implements IPartHelper
AELog.info( "Layer " + layer + " not registered, " + layerInterface + " already has a layer." );
}
}
catch( Throwable ignored )
catch( final Throwable ignored )
{
}
@@ -328,7 +328,7 @@ public class ApiPart implements IPartHelper
}
@Override
public void setItemBusRenderer( IPartItem i )
public void setItemBusRenderer( final IPartItem i )
{
if( Platform.isClient() && i instanceof Item )
{
@@ -338,7 +338,7 @@ public class ApiPart implements IPartHelper
}
@Override
public boolean placeBus( ItemStack is, BlockPos pos, EnumFacing side, EntityPlayer player, World w )
public boolean placeBus( final ItemStack is, final BlockPos pos, final EnumFacing side, final EntityPlayer player, final World w )
{
return PartPlacement.place( is, pos, side, player, w, PartPlacement.PlaceType.PLACE_ITEM, 0 );
}
@@ -355,9 +355,9 @@ public class ApiPart implements IPartHelper
public final HashMap<String, String> inputOutput = new HashMap<String, String>();
@Override
public String map( String typeName )
public String map( final String typeName )
{
String o = this.inputOutput.get( typeName );
final String o = this.inputOutput.get( typeName );
if( o == null )
{
return typeName;
@@ -47,19 +47,19 @@ public class ApiStorage implements IStorageHelper
{
@Override
public ICraftingLink loadCraftingLink( NBTTagCompound data, ICraftingRequester req )
public ICraftingLink loadCraftingLink( final NBTTagCompound data, final ICraftingRequester req )
{
return new CraftingLink( data, req );
}
@Override
public IAEItemStack createItemStack( ItemStack is )
public IAEItemStack createItemStack( final ItemStack is )
{
return AEItemStack.create( is );
}
@Override
public IAEFluidStack createFluidStack( FluidStack is )
public IAEFluidStack createFluidStack( final FluidStack is )
{
return AEFluidStack.create( is );
}
@@ -77,25 +77,25 @@ public class ApiStorage implements IStorageHelper
}
@Override
public IAEItemStack readItemFromPacket( ByteBuf input ) throws IOException
public IAEItemStack readItemFromPacket( final ByteBuf input ) throws IOException
{
return AEItemStack.loadItemStackFromPacket( input );
}
@Override
public IAEFluidStack readFluidFromPacket( ByteBuf input ) throws IOException
public IAEFluidStack readFluidFromPacket( final ByteBuf input ) throws IOException
{
return AEFluidStack.loadFluidStackFromPacket( input );
}
@Override
public IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src )
public IAEItemStack poweredExtraction( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack request, final BaseActionSource src )
{
return Platform.poweredExtraction( energy, cell, request, src );
}
@Override
public IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src )
public IAEItemStack poweredInsert( final IEnergySource energy, final IMEInventory<IAEItemStack> cell, final IAEItemStack input, final BaseActionSource src )
{
return Platform.poweredInsert( energy, cell, input, src );
}
@@ -159,7 +159,7 @@ public final class ApiBlocks implements IBlocks
private final IBlockDefinition phantomNode;
private final IBlockDefinition cubeGenerator;
public ApiBlocks( DefinitionConstructor constructor )
public ApiBlocks( final DefinitionConstructor constructor )
{
// this.quartzOre = new BlockDefinition( "ore.quartz", new OreQuartz() );
this.quartzOre = constructor.registerBlockDefinition( new QuartzOreBlock() );
@@ -242,9 +242,9 @@ public final class ApiBlocks implements IBlocks
this.cubeGenerator = constructor.registerBlockDefinition( new BlockCubeGenerator() );
}
private IBlockDefinition makeStairs( DefinitionConstructor constructor, IBlockDefinition definition, String name )
private IBlockDefinition makeStairs( final DefinitionConstructor constructor, final IBlockDefinition definition, final String name )
{
for( Block block : definition.maybeBlock().asSet() )
for( final Block block : definition.maybeBlock().asSet() )
{
return constructor.registerBlockDefinition( new BlockStairCommon( block, name ) );
}
@@ -113,7 +113,7 @@ public final class ApiItems implements IItems
private final IItemDefinition toolDebugCard;
private final IItemDefinition toolReplicatorCard;
public ApiItems( DefinitionConstructor constructor )
public ApiItems( final DefinitionConstructor constructor )
{
this.certusQuartzAxe = constructor.registerItemDefinition( new ToolQuartzAxe( AEFeature.CertusQuartzTools ) );
this.certusQuartzHoe = constructor.registerItemDefinition( new ToolQuartzHoe( AEFeature.CertusQuartzTools ) );
@@ -103,7 +103,7 @@ public final class ApiMaterials implements IMaterials
private final IItemDefinition qESingularity;
private final IItemDefinition blankPattern;
public ApiMaterials( DefinitionConstructor constructor )
public ApiMaterials( final DefinitionConstructor constructor )
{
final MultiItem materials = new MultiItem();
constructor.registerItemDefinition( materials );
@@ -73,7 +73,7 @@ public final class ApiParts implements IParts
private final IItemDefinition storageMonitor;
private final IItemDefinition conversionMonitor;
public ApiParts( DefinitionConstructor constructor, IPartHelper partHelper )
public ApiParts( final DefinitionConstructor constructor, final IPartHelper partHelper )
{
final ItemMultiPart itemMultiPart = new ItemMultiPart( partHelper );
constructor.registerItemDefinition( itemMultiPart );
@@ -41,13 +41,13 @@ public class DefinitionConstructor
private final FeatureRegistry features;
private final FeatureHandlerRegistry handlers;
public DefinitionConstructor( FeatureRegistry features, FeatureHandlerRegistry handlers )
public DefinitionConstructor( final FeatureRegistry features, final FeatureHandlerRegistry handlers )
{
this.features = features;
this.handlers = handlers;
}
public final ITileDefinition registerTileDefinition( IAEFeature feature )
public final ITileDefinition registerTileDefinition( final IAEFeature feature )
{
final IBlockDefinition definition = this.registerBlockDefinition( feature );
@@ -59,7 +59,7 @@ public class DefinitionConstructor
throw new IllegalStateException( "No tile definition for " + feature );
}
public final IBlockDefinition registerBlockDefinition( IAEFeature feature )
public final IBlockDefinition registerBlockDefinition( final IAEFeature feature )
{
final IItemDefinition definition = this.registerItemDefinition( feature );
@@ -71,7 +71,7 @@ public class DefinitionConstructor
throw new IllegalStateException( "No block definition for " + feature );
}
public final IItemDefinition registerItemDefinition( IAEFeature feature )
public final IItemDefinition registerItemDefinition( final IAEFeature feature )
{
final IFeatureHandler handler = feature.handler();
@@ -86,13 +86,13 @@ public class DefinitionConstructor
return definition;
}
public final AEColoredItemDefinition constructColoredDefinition( IItemDefinition target, int offset )
public final AEColoredItemDefinition constructColoredDefinition( final IItemDefinition target, final int offset )
{
final ColoredItemDefinition definition = new ColoredItemDefinition();
for( Item targetItem : target.maybeItem().asSet() )
for( final Item targetItem : target.maybeItem().asSet() )
{
for( AEColor color : AEColor.VALID_COLORS )
for( final AEColor color : AEColor.VALID_COLORS )
{
final ActivityState state = ActivityState.from( target.isEnabled() );
@@ -103,11 +103,11 @@ public class DefinitionConstructor
return definition;
}
public final AEColoredItemDefinition constructColoredDefinition( ItemMultiPart target, PartType type )
public final AEColoredItemDefinition constructColoredDefinition( final ItemMultiPart target, final PartType type )
{
final ColoredItemDefinition definition = new ColoredItemDefinition();
for( AEColor color : AEColor.values() )
for( final AEColor color : AEColor.values() )
{
final ItemStackSrc multiPartSource = target.createPart( type, color );
@@ -31,13 +31,13 @@ public class IMCBlackListSpatial implements IIMCProcessor
{
@Override
public void process( IMCMessage m )
public void process( final IMCMessage m )
{
ItemStack is = m.getItemStackValue();
final ItemStack is = m.getItemStackValue();
if( is != null )
{
Block blk = Block.getBlockFromItem( is.getItem() );
final Block blk = Block.getBlockFromItem( is.getItem() );
if( blk != null )
{
AEApi.instance().registries().movable().blacklistBlock( blk );
@@ -63,16 +63,16 @@ import appeng.core.api.IIMCProcessor;
public class IMCGrinder implements IIMCProcessor
{
@Override
public void process( IMCMessage m )
public void process( final IMCMessage m )
{
NBTTagCompound msg = m.getNBTValue();
NBTTagCompound inTag = (NBTTagCompound) msg.getTag( "in" );
NBTTagCompound outTag = (NBTTagCompound) msg.getTag( "out" );
final NBTTagCompound msg = m.getNBTValue();
final NBTTagCompound inTag = (NBTTagCompound) msg.getTag( "in" );
final NBTTagCompound outTag = (NBTTagCompound) msg.getTag( "out" );
ItemStack in = ItemStack.loadItemStackFromNBT( inTag );
ItemStack out = ItemStack.loadItemStackFromNBT( outTag );
final ItemStack in = ItemStack.loadItemStackFromNBT( inTag );
final ItemStack out = ItemStack.loadItemStackFromNBT( outTag );
int turns = msg.getInteger( "turns" );
final int turns = msg.getInteger( "turns" );
if( in == null )
{
@@ -86,15 +86,15 @@ public class IMCGrinder implements IIMCProcessor
if( msg.hasKey( "optional" ) )
{
NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" );
ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
final NBTTagCompound optionalTag = (NBTTagCompound) msg.getTag( "optional" );
final ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag );
if( optional == null )
{
throw new IllegalStateException( "invalid optional" );
}
float chance = msg.getFloat( "chance" );
final float chance = msg.getFloat( "chance" );
AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns );
}
@@ -43,13 +43,13 @@ public class IMCMatterCannon implements IIMCProcessor
{
@Override
public void process( IMCMessage m )
public void process( final IMCMessage m )
{
NBTTagCompound msg = m.getNBTValue();
NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" );
final NBTTagCompound msg = m.getNBTValue();
final NBTTagCompound item = (NBTTagCompound) msg.getTag( "item" );
ItemStack ammo = ItemStack.loadItemStackFromNBT( item );
double weight = msg.getDouble( "weight" );
final ItemStack ammo = ItemStack.loadItemStackFromNBT( item );
final double weight = msg.getDouble( "weight" );
if( ammo == null )
{
@@ -44,15 +44,15 @@ public class IMCP2PAttunement implements IIMCProcessor
{
@Override
public void process( IMCMessage m )
public void process( final IMCMessage m )
{
String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase( Locale.ENGLISH );
final String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase( Locale.ENGLISH );
TunnelType type = TunnelType.valueOf( key );
final TunnelType type = TunnelType.valueOf( key );
if( type != null )
{
ItemStack is = m.getItemStackValue();
final ItemStack is = m.getItemStackValue();
if( is != null )
{
AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type );
@@ -35,15 +35,15 @@ public class IMCSpatial implements IIMCProcessor
{
@Override
public void process( IMCMessage m )
public void process( final IMCMessage m )
{
try
{
Class classInstance = Class.forName( m.getStringValue() );
final Class classInstance = Class.forName( m.getStringValue() );
AEApi.instance().registries().movable().whiteListTileEntity( classInstance );
}
catch( ClassNotFoundException e )
catch( final ClassNotFoundException e )
{
AELog.info( "Bad Class Registered: " + m.getStringValue() + " by " + m.getSender() );
}