From 3783ae861990d295c2747da708cdc56abe40f9a1 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Mon, 23 Mar 2015 10:14:35 +0100 Subject: [PATCH] Improved exceptions Many exceptions got an improvement due to changed class or description or details it is providing. Is not complete, needs to be done in patches in the regions, where it is needed, since some are just swallowed. Removed total usage of pure RuntimeExceptions to 0. --- src/api/java/appeng/api/config/Settings.java | 16 +++--- src/main/java/appeng/block/AEBaseBlock.java | 19 ++++--- src/main/java/appeng/client/ClientHelper.java | 3 -- .../java/appeng/client/gui/AEBaseGui.java | 10 ---- .../appeng/client/render/BaseBlockRender.java | 3 -- .../appeng/client/render/BusRenderHelper.java | 2 +- .../appeng/client/render/TESRWrapper.java | 9 +--- .../blocks/RenderBlockCraftingCPUMonitor.java | 3 -- .../appeng/client/texture/FlippableIcon.java | 3 +- .../java/appeng/client/texture/FullIcon.java | 3 +- .../appeng/client/texture/OffsetIcon.java | 3 +- .../appeng/client/texture/TaughtIcon.java | 21 ++++---- .../appeng/container/AEBaseContainer.java | 4 +- src/main/java/appeng/core/Api.java | 5 +- src/main/java/appeng/core/IMCHandler.java | 2 +- src/main/java/appeng/core/Registration.java | 2 +- src/main/java/appeng/core/WorldSettings.java | 10 ++-- src/main/java/appeng/core/api/ApiPart.java | 41 ++++++-------- .../definitions/DefinitionConstructor.java | 4 +- .../java/appeng/core/api/imc/IMCGrinder.java | 6 +-- .../appeng/core/api/imc/IMCMatterCannon.java | 2 +- .../appeng/core/api/imc/IMCP2PAttunement.java | 6 ++- .../registries/GridCacheRegistry.java | 31 ++++++++--- .../registries/MovableTileRegistry.java | 3 +- .../java/appeng/core/sync/AppEngPacket.java | 4 +- .../core/sync/AppEngPacketHandlerBase.java | 2 +- src/main/java/appeng/core/sync/GuiBridge.java | 14 ++--- .../sync/packets/PacketInventoryAction.java | 2 +- .../java/appeng/crafting/CraftingJob.java | 2 +- .../java/appeng/crafting/CraftingLink.java | 4 +- .../appeng/crafting/CraftingTreeProcess.java | 2 +- src/main/java/appeng/entity/EntityIds.java | 2 +- src/main/java/appeng/facade/FacadePart.java | 2 +- src/main/java/appeng/fmp/PartRegistry.java | 5 +- .../java/appeng/helpers/DualityInterface.java | 6 +-- .../java/appeng/helpers/MetaRotation.java | 2 +- .../java/appeng/helpers/PatternHelper.java | 10 ++-- .../integration/IntegrationRegistry.java | 3 +- .../appeng/integration/modules/InvTweaks.java | 2 +- .../java/appeng/integration/modules/NEI.java | 2 +- .../NEIHelpers/NEIWorldCraftingHandler.java | 8 ++- .../items/materials/ItemMultiMaterial.java | 6 +-- .../appeng/items/parts/ItemMultiPart.java | 11 ++-- src/main/java/appeng/me/GridNode.java | 2 +- src/main/java/appeng/me/NetworkEventBus.java | 8 +-- .../appeng/me/cache/CraftingGridCache.java | 2 +- .../java/appeng/me/cache/NetworkMonitor.java | 2 +- .../implementations/CraftingCPUCluster.java | 4 +- .../me/storage/NetworkInventoryHandler.java | 2 +- .../java/appeng/parts/CableBusContainer.java | 7 +-- .../java/appeng/parts/p2p/PartP2PLiquids.java | 6 +-- .../java/appeng/parts/p2p/PartP2PRFPower.java | 6 +-- .../parts/reporting/PartStorageMonitor.java | 2 - .../java/appeng/recipes/RecipeHandler.java | 7 ++- .../appeng/recipes/game/ShapedRecipe.java | 4 +- .../appeng/recipes/game/ShapelessRecipe.java | 2 +- .../appeng/recipes/handlers/MekCrusher.java | 1 + src/main/java/appeng/server/AECommand.java | 5 +- src/main/java/appeng/server/ServerHelper.java | 6 +-- .../services/version/VersionParser.java | 3 +- .../tile/crafting/TileCraftingTile.java | 2 +- .../tile/events/AETileEventHandler.java | 30 +++++------ .../java/appeng/tile/storage/TileChest.java | 1 - .../appeng/transformer/MissingCoreMod.java | 53 ++++++++++++------- .../transformer/asm/ASMIntegration.java | 8 +-- src/main/java/appeng/util/ConfigManager.java | 2 +- src/main/java/appeng/util/Platform.java | 12 ++--- .../appeng/util/inv/IMEAdaptorIterator.java | 16 +++--- .../java/appeng/util/item/AEFluidStack.java | 8 ++- src/main/java/appeng/util/item/ItemList.java | 2 +- .../appeng/util/iterators/AEInvIterator.java | 25 ++++----- .../util/iterators/ChainedIterator.java | 8 +-- .../appeng/util/iterators/InvIterator.java | 24 ++++----- .../util/iterators/ProxyNodeIterator.java | 7 ++- .../util/prioitylist/IPartitionList.java | 1 - .../util/prioitylist/MergedPriorityList.java | 10 ++-- 76 files changed, 288 insertions(+), 290 deletions(-) diff --git a/src/api/java/appeng/api/config/Settings.java b/src/api/java/appeng/api/config/Settings.java index 1ebf42770..97796dc28 100644 --- a/src/api/java/appeng/api/config/Settings.java +++ b/src/api/java/appeng/api/config/Settings.java @@ -25,6 +25,7 @@ package appeng.api.config; import java.util.EnumSet; +import javax.annotation.Nonnull; public enum Settings @@ -55,16 +56,19 @@ public enum Settings STORAGE_FILTER( EnumSet.allOf( StorageFilter.class ) ), PLACE_BLOCK( EnumSet.of( YesNo.YES, YesNo.NO ) ); - private final EnumSet values; + private final EnumSet> values; - Settings( EnumSet set ) + Settings( @Nonnull EnumSet> possibleOptions ) { - if( set == null || set.isEmpty() ) - throw new RuntimeException( "Invalid configuration." ); - this.values = set; + if ( possibleOptions.isEmpty() ) + { + throw new IllegalArgumentException( "Tried to instantiate an empty setting." ); + } + + this.values = possibleOptions; } - public EnumSet getPossibleValues() + public EnumSet> getPossibleValues() { return this.values; } diff --git a/src/main/java/appeng/block/AEBaseBlock.java b/src/main/java/appeng/block/AEBaseBlock.java index 4443b7149..7c35b71ee 100644 --- a/src/main/java/appeng/block/AEBaseBlock.java +++ b/src/main/java/appeng/block/AEBaseBlock.java @@ -156,11 +156,18 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature try { - return this.renderInfo = new BlockRenderInfo( this.getRenderer().newInstance() ); + final BaseBlockRender renderer = this.getRenderer().newInstance(); + this.renderInfo = new BlockRenderInfo( renderer ); + + return this.renderInfo; } - catch( Throwable t ) + catch ( InstantiationException e ) { - throw new RuntimeException( t ); + throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.getRenderer(), e ); + } + catch( IllegalAccessException e ) + { + throw new IllegalStateException( "Failed to create a new instance of " + this.getRenderer() + " because of permissions.", e ); } } @@ -797,13 +804,11 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature } catch( InstantiationException e ) { - e.printStackTrace(); - throw new RuntimeException( e ); + throw new IllegalStateException( "Failed to create a new instance of an illegal class " + this.tileEntityType , e ); } catch( IllegalAccessException e ) { - e.printStackTrace(); - throw new RuntimeException( e ); + throw new IllegalStateException( "Failed to create a new instance of " + this.tileEntityType + ", because lack of permissions", e ); } } diff --git a/src/main/java/appeng/client/ClientHelper.java b/src/main/java/appeng/client/ClientHelper.java index 87cdf81f6..4a7062920 100644 --- a/src/main/java/appeng/client/ClientHelper.java +++ b/src/main/java/appeng/client/ClientHelper.java @@ -364,9 +364,6 @@ public class ClientHelper extends ServerHelper EntityPlayer player = mc.thePlayer; - if( player == null ) - return; - int x = (int) player.posX; int y = (int) player.posY; int z = (int) player.posZ; diff --git a/src/main/java/appeng/client/gui/AEBaseGui.java b/src/main/java/appeng/client/gui/AEBaseGui.java index 33df07862..a8e0edfb2 100644 --- a/src/main/java/appeng/client/gui/AEBaseGui.java +++ b/src/main/java/appeng/client/gui/AEBaseGui.java @@ -79,7 +79,6 @@ import appeng.core.sync.packets.PacketSwapSlots; import appeng.helpers.InventoryAction; import appeng.integration.IntegrationType; import appeng.integration.abstraction.INEI; -import appeng.util.Platform; public abstract class AEBaseGui extends GuiContainer @@ -744,8 +743,6 @@ public abstract class AEBaseGui extends GuiContainer catch( Exception err ) { AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() ); - if( Platform.isDrawing( Tessellator.instance ) ) - Tessellator.instance.draw(); } this.setItemRender( pIR ); return; @@ -794,8 +791,6 @@ public abstract class AEBaseGui extends GuiContainer } catch( Exception err ) { - if( Platform.isDrawing( tessellator ) ) - tessellator.draw(); } GL11.glPopAttrib(); } @@ -876,15 +871,10 @@ public abstract class AEBaseGui extends GuiContainer { try { - // drawSlotInventory - // super.func_146977_a( s );r GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s ); } catch( Exception err ) { - Tessellator tessellator = Tessellator.instance; - if( Platform.isDrawing( tessellator ) ) - tessellator.draw(); } } diff --git a/src/main/java/appeng/client/render/BaseBlockRender.java b/src/main/java/appeng/client/render/BaseBlockRender.java index aa349c56d..a90446e2e 100644 --- a/src/main/java/appeng/client/render/BaseBlockRender.java +++ b/src/main/java/appeng/client/render/BaseBlockRender.java @@ -325,9 +325,6 @@ public class BaseBlockRender public void renderInvBlock( EnumSet sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer ) { - if( Platform.isDrawing( tess ) ) - tess.draw(); - int meta = 0; if( block != null && block.hasSubtypes() && item != null ) meta = item.getItemDamage(); diff --git a/src/main/java/appeng/client/render/BusRenderHelper.java b/src/main/java/appeng/client/render/BusRenderHelper.java index 6282331d0..157db49ce 100644 --- a/src/main/java/appeng/client/render/BusRenderHelper.java +++ b/src/main/java/appeng/client/render/BusRenderHelper.java @@ -472,7 +472,7 @@ public final class BusRenderHelper implements IPartRenderHelper return block; } - throw new MissingDefinition( "Tried to access the multi part block." ); + throw new MissingDefinition( "Tried to access the multi part block without it being defined." ); } public void prepareBounds( RenderBlocks renderer ) diff --git a/src/main/java/appeng/client/render/TESRWrapper.java b/src/main/java/appeng/client/render/TESRWrapper.java index 849b1c810..5b6f96733 100644 --- a/src/main/java/appeng/client/render/TESRWrapper.java +++ b/src/main/java/appeng/client/render/TESRWrapper.java @@ -33,7 +33,6 @@ import cpw.mods.fml.relauncher.SideOnly; import appeng.block.AEBaseBlock; import appeng.core.AELog; import appeng.tile.AEBaseTile; -import appeng.util.Platform; @SideOnly( Side.CLIENT ) @@ -65,9 +64,6 @@ public class TESRWrapper extends TileEntitySpecialRenderer Tessellator tess = Tessellator.instance; - if( Platform.isDrawing( tess ) ) - return; - try { GL11.glPushMatrix(); @@ -76,9 +72,6 @@ public class TESRWrapper extends TileEntitySpecialRenderer this.renderBlocksInstance.blockAccess = te.getWorldObj(); this.blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, this.renderBlocksInstance ); - if( Platform.isDrawing( tess ) ) - throw new RuntimeException( "Error during rendering." ); - GL11.glPopAttrib(); GL11.glPopMatrix(); } @@ -87,7 +80,7 @@ public class TESRWrapper extends TileEntitySpecialRenderer AELog.severe( "Hi, Looks like there was a crash while rendering something..." ); t.printStackTrace(); AELog.severe( "MC will now crash ( probably )!" ); - throw new RuntimeException( t ); + throw new IllegalStateException( t ); } } } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java index a68753efa..5ac86ff84 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java @@ -53,9 +53,6 @@ public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU @Override public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer ) { - if( Platform.isDrawing( tess ) ) - return; - if( tile instanceof TileCraftingMonitorTile ) { TileCraftingMonitorTile cmt = (TileCraftingMonitorTile) tile; diff --git a/src/main/java/appeng/client/texture/FlippableIcon.java b/src/main/java/appeng/client/texture/FlippableIcon.java index aa2aee330..489bbe1bc 100644 --- a/src/main/java/appeng/client/texture/FlippableIcon.java +++ b/src/main/java/appeng/client/texture/FlippableIcon.java @@ -31,9 +31,8 @@ public class FlippableIcon implements IIcon public FlippableIcon( IIcon o ) { - if( o == null ) - throw new RuntimeException( "Cannot create a wrapper icon with a null icon." ); + throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); this.original = o; this.flip_u = false; diff --git a/src/main/java/appeng/client/texture/FullIcon.java b/src/main/java/appeng/client/texture/FullIcon.java index ea289f1f7..cf369504c 100644 --- a/src/main/java/appeng/client/texture/FullIcon.java +++ b/src/main/java/appeng/client/texture/FullIcon.java @@ -32,9 +32,8 @@ public class FullIcon implements IIcon public FullIcon( IIcon o ) { - if( o == null ) - throw new RuntimeException( "Cannot create a wrapper icon with a null icon." ); + throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); this.p = o; } diff --git a/src/main/java/appeng/client/texture/OffsetIcon.java b/src/main/java/appeng/client/texture/OffsetIcon.java index 44487ddbb..30bfb05ab 100644 --- a/src/main/java/appeng/client/texture/OffsetIcon.java +++ b/src/main/java/appeng/client/texture/OffsetIcon.java @@ -35,9 +35,8 @@ public class OffsetIcon implements IIcon public OffsetIcon( IIcon o, float x, float y ) { - if( o == null ) - throw new RuntimeException( "Cannot create a wrapper icon with a null icon." ); + throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); this.p = o; this.offsetX = x; diff --git a/src/main/java/appeng/client/texture/TaughtIcon.java b/src/main/java/appeng/client/texture/TaughtIcon.java index 58eb34455..298b85724 100644 --- a/src/main/java/appeng/client/texture/TaughtIcon.java +++ b/src/main/java/appeng/client/texture/TaughtIcon.java @@ -30,28 +30,27 @@ public class TaughtIcon implements IIcon final float tightness; - private final IIcon p; + private final IIcon icon; - public TaughtIcon( IIcon o, float tightness ) + public TaughtIcon( IIcon icon, float tightness ) { + if( icon == null ) + throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); - if( o == null ) - throw new RuntimeException( "Cannot create a wrapper icon with a null icon." ); - - this.p = o; + this.icon = icon; this.tightness = tightness * 0.4f; } @Override public int getIconWidth() { - return this.p.getIconWidth(); + return this.icon.getIconWidth(); } @Override public int getIconHeight() { - return this.p.getIconHeight(); + return this.icon.getIconHeight(); } @Override @@ -100,7 +99,7 @@ public class TaughtIcon implements IIcon @SideOnly( Side.CLIENT ) public String getIconName() { - return this.p.getIconName(); + return this.icon.getIconName(); } private float v( double d ) @@ -109,7 +108,7 @@ public class TaughtIcon implements IIcon d -= this.tightness; if( d > 8 ) d += this.tightness; - return this.p.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) ); + return this.icon.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) ); } private float u( double d ) @@ -118,6 +117,6 @@ public class TaughtIcon implements IIcon d -= this.tightness; if( d > 8 ) d += this.tightness; - return this.p.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) ); + return this.icon.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) ); } } diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index 3ab458f4c..2f604e8c4 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -154,7 +154,7 @@ public abstract class AEBaseContainer extends Container this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null; if( this.tileEntity == null && this.part == null && this.obj == null ) - throw new RuntimeException( "Must have a valid anchor" ); + throw new IllegalArgumentException( "Must have a valid anchor, instead " + anchor + " in " + ip ); this.mySrc = new PlayerSource( ip.player, this.getActionHost() ); @@ -380,7 +380,7 @@ public abstract class AEBaseContainer extends Container return super.addSlotToContainer( newSlot ); } else - throw new RuntimeException( "Invalid Slot for AE Container." ); + throw new IllegalArgumentException( "Invalid Slot [" + newSlot + "]for AE Container instead of AppEngSlot." ); } @Override diff --git a/src/main/java/appeng/core/Api.java b/src/main/java/appeng/core/Api.java index f1032abf7..bd1579664 100644 --- a/src/main/java/appeng/core/Api.java +++ b/src/main/java/appeng/core/Api.java @@ -119,8 +119,9 @@ public final class Api implements IAppEngApi @Override public IGridNode createGridNode( IGridBlock blk ) { - if( Platform.isClient() ) - throw new RuntimeException( "Grid Features are Server Side Only." ); + if ( Platform.isClient() ) + throw new IllegalStateException( "Grid features for " + blk + " are server side only." ); + return new GridNode( blk ); } diff --git a/src/main/java/appeng/core/IMCHandler.java b/src/main/java/appeng/core/IMCHandler.java index 5fae71a26..743b19f0f 100644 --- a/src/main/java/appeng/core/IMCHandler.java +++ b/src/main/java/appeng/core/IMCHandler.java @@ -85,7 +85,7 @@ public class IMCHandler } else { - throw new RuntimeException( "Invalid IMC Called: " + key ); + throw new IllegalStateException( "Invalid IMC Called: " + key ); } } catch( Throwable t ) diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 8e605c4de..4b643d539 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -189,7 +189,7 @@ public final class Registration { config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() ); if( config.storageBiomeID == -1 ) - throw new RuntimeException( "Biome Array is full, please free up some Biome ID's or disable spatial." ); + throw new IllegalStateException( "Biome Array is full, please free up some Biome ID's or disable spatial." ); this.storageBiome = new BiomeGenStorage( config.storageBiomeID ); config.save(); diff --git a/src/main/java/appeng/core/WorldSettings.java b/src/main/java/appeng/core/WorldSettings.java index 07c5a1f4c..8845f6145 100644 --- a/src/main/java/appeng/core/WorldSettings.java +++ b/src/main/java/appeng/core/WorldSettings.java @@ -105,19 +105,19 @@ public class WorldSettings extends Configuration if( !aeBaseFolder.isDirectory() && !aeBaseFolder.mkdir() ) { - throw new RuntimeException( "Failed to create " + aeBaseFolder.getAbsolutePath() ); + throw new IllegalStateException( "Failed to create " + aeBaseFolder.getAbsolutePath() ); } File compass = new File( aeBaseFolder, COMPASS_FOLDER ); if( !compass.isDirectory() && !compass.mkdir() ) { - throw new RuntimeException( "Failed to create " + compass.getAbsolutePath() ); + throw new IllegalStateException( "Failed to create " + compass.getAbsolutePath() ); } File spawnData = new File( aeBaseFolder, SPAWNDATA_FOLDER ); if( !spawnData.isDirectory() && !spawnData.mkdir() ) { - throw new RuntimeException( "Failed to create " + spawnData.getAbsolutePath() ); + throw new IllegalStateException( "Failed to create " + spawnData.getAbsolutePath() ); } instance = new WorldSettings( aeBaseFolder ); @@ -158,7 +158,7 @@ public class WorldSettings extends Configuration NBTTagCompound loadSpawnData( int dim, int chunkX, int chunkZ ) { if( !Thread.holdsLock( WorldSettings.class ) ) - throw new RuntimeException( "Invalid Request" ); + throw new IllegalStateException( "Invalid Request" ); NBTTagCompound data = null; File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" ); @@ -225,7 +225,7 @@ public class WorldSettings extends Configuration void writeSpawnData( int dim, int chunkX, int chunkZ, NBTTagCompound data ) { if( !Thread.holdsLock( WorldSettings.class ) ) - throw new RuntimeException( "Invalid Request" ); + throw new IllegalStateException( "Invalid Request" ); File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" ); FileOutputStream fileOutputStream = null; diff --git a/src/main/java/appeng/core/api/ApiPart.java b/src/main/java/appeng/core/api/ApiPart.java index b1383024b..ea302965a 100644 --- a/src/main/java/appeng/core/api/ApiPart.java +++ b/src/main/java/appeng/core/api/ApiPart.java @@ -19,6 +19,7 @@ package appeng.core.api; +import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import java.util.HashMap; @@ -85,9 +86,9 @@ public class ApiPart implements IPartHelper { return Class.forName( base ); } - catch( Throwable t ) + catch( ClassNotFoundException e ) { - throw new RuntimeException( t ); + throw new IllegalStateException( e ); } } @@ -95,14 +96,7 @@ public class ApiPart implements IPartHelper if( this.tileImplementations.get( description ) != null ) { - try - { - return this.tileImplementations.get( description ); - } - catch( Throwable t ) - { - throw new RuntimeException( t ); - } + return this.tileImplementations.get( description ); } String f = base;// TileCableBus.class.getName(); @@ -121,9 +115,9 @@ public class ApiPart implements IPartHelper { myCLass = Class.forName( f ); } - catch( Throwable t ) + catch( ClassNotFoundException e ) { - throw new RuntimeException( t ); + throw new IllegalStateException( e ); } String path = f; @@ -147,14 +141,7 @@ public class ApiPart implements IPartHelper this.tileImplementations.put( description, myCLass ); - try - { - return myCLass; - } - catch( Throwable t ) - { - throw new RuntimeException( t ); - } + return myCLass; } public Class getClassByDesc( String Addendum, String fullPath, String root, String next ) @@ -247,19 +234,21 @@ public class ApiPart implements IPartHelper public ClassNode getReader( String name ) { + ClassReader cr; + String path = '/' + name.replace( ".", "/" ) + ".class"; + InputStream is = this.getClass().getResourceAsStream( path ); try { - ClassReader cr; - String path = '/' + name.replace( ".", "/" ) + ".class"; - InputStream is = this.getClass().getResourceAsStream( path ); cr = new ClassReader( is ); + ClassNode cn = new ClassNode(); cr.accept( cn, ClassReader.EXPAND_FRAMES ); + return cn; } - catch( Throwable t ) + catch( IOException e ) { - throw new RuntimeException( "Error loading " + name, t ); + throw new IllegalStateException( "Error loading " + name, e ); } } @@ -306,7 +295,7 @@ public class ApiPart implements IPartHelper catch( Exception e ) { AELog.error( e ); - throw new RuntimeException( "Unable to manage part API.", e ); + throw new IllegalStateException( "Unable to manage part API.", e ); } return clazz; } diff --git a/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java b/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java index 0ae1d5ffb..9addd1eb6 100644 --- a/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java +++ b/src/main/java/appeng/core/api/definitions/DefinitionConstructor.java @@ -40,7 +40,7 @@ public class DefinitionConstructor return ( (ITileDefinition) definition ); } - throw new RuntimeException( "No tile definition" ); + throw new IllegalStateException( "No tile definition for " + feature ); } public final IBlockDefinition registerBlockDefinition( IAEFeature feature ) @@ -52,7 +52,7 @@ public class DefinitionConstructor return ( (IBlockDefinition) definition ); } - throw new RuntimeException( "No block definition" ); + throw new IllegalStateException( "No block definition for " + feature ); } public final IItemDefinition registerItemDefinition( IAEFeature feature ) diff --git a/src/main/java/appeng/core/api/imc/IMCGrinder.java b/src/main/java/appeng/core/api/imc/IMCGrinder.java index 2a902c78c..d272d2cad 100644 --- a/src/main/java/appeng/core/api/imc/IMCGrinder.java +++ b/src/main/java/appeng/core/api/imc/IMCGrinder.java @@ -77,10 +77,10 @@ public class IMCGrinder implements IIMCProcessor int turns = msg.getInteger( "turns" ); if( in == null ) - throw new RuntimeException( "invalid input" ); + throw new IllegalStateException( "invalid input" ); if( out == null ) - throw new RuntimeException( "invalid output" ); + throw new IllegalStateException( "invalid output" ); if( msg.hasKey( "optional" ) ) { @@ -88,7 +88,7 @@ public class IMCGrinder implements IIMCProcessor ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag ); if( optional == null ) - throw new RuntimeException( "invalid optional" ); + throw new IllegalStateException( "invalid optional" ); float chance = msg.getFloat( "chance" ); diff --git a/src/main/java/appeng/core/api/imc/IMCMatterCannon.java b/src/main/java/appeng/core/api/imc/IMCMatterCannon.java index 81e574c86..d990a6bb7 100644 --- a/src/main/java/appeng/core/api/imc/IMCMatterCannon.java +++ b/src/main/java/appeng/core/api/imc/IMCMatterCannon.java @@ -54,7 +54,7 @@ public class IMCMatterCannon implements IIMCProcessor double weight = msg.getDouble( "weight" ); if( ammo == null ) - throw new RuntimeException( "invalid item" ); + throw new IllegalStateException( "invalid item in message " + m ); AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight ); } diff --git a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java index 40dd1cd32..4a6a4e529 100644 --- a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java +++ b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java @@ -30,6 +30,8 @@ FMLInterModComms.sendMessage( "appliedenergistics2", "add-p2p-attunement-item", package appeng.core.api.imc; +import java.util.Arrays; + import net.minecraft.item.ItemStack; import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; @@ -55,9 +57,9 @@ public class IMCP2PAttunement implements IIMCProcessor if( is != null ) AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type ); else - throw new RuntimeException( "invalid item" ); + throw new IllegalStateException( "invalid item in message " + m ); } else - throw new RuntimeException( "invalid type" ); + throw new IllegalStateException( "invalid type in message " + m + " is not contained in " + Arrays.toString( TunnelType.values() ) ); } } diff --git a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java index a44100c98..b5a5d5665 100644 --- a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java +++ b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java @@ -20,7 +20,9 @@ package appeng.core.features.registries; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; +import java.util.Map; import appeng.api.networking.IGrid; import appeng.api.networking.IGridCache; @@ -28,10 +30,9 @@ import appeng.api.networking.IGridCacheRegistry; import appeng.core.AELog; -public class GridCacheRegistry implements IGridCacheRegistry +public final class GridCacheRegistry implements IGridCacheRegistry { - - private final HashMap, Class> caches = new HashMap, Class>(); + private final Map, Class> caches = new HashMap, Class>(); @Override public void registerGridCache( Class iface, Class implementation ) @@ -39,7 +40,7 @@ public class GridCacheRegistry implements IGridCacheRegistry if( iface.isAssignableFrom( implementation ) ) this.caches.put( iface, implementation ); else - throw new RuntimeException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements" ); + throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation ); } @Override @@ -49,15 +50,31 @@ public class GridCacheRegistry implements IGridCacheRegistry for( Class iface : this.caches.keySet() ) { + Constructor c; try { - Constructor c = this.caches.get( iface ).getConstructor( IGrid.class ); + c = this.caches.get( iface ).getConstructor( IGrid.class ); map.put( iface, c.newInstance( g ) ); } - catch( Throwable e ) + catch( NoSuchMethodException e ) { AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." ); - throw new RuntimeException( e ); + throw new IllegalArgumentException( e ); + } + catch( InvocationTargetException e ) + { + AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." ); + throw new IllegalStateException( e ); + } + catch( InstantiationException e ) + { + AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." ); + throw new IllegalStateException( e ); + } + catch( IllegalAccessException e ) + { + AELog.severe( "Grid Caches must have a constructor with IGrid as the single param." ); + throw new IllegalStateException( e ); } } diff --git a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java index e6d93bdcb..20a75816a 100644 --- a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java +++ b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java @@ -54,10 +54,9 @@ public class MovableTileRegistry implements IMovableRegistry @Override public void whiteListTileEntity( Class c ) { - if( c.getName().equals( TileEntity.class.getName() ) ) { - throw new RuntimeException( new AppEngException( "Someone tried to make all tiles movable, this is a clear violation of the purpose of the white list." ) ); + throw new IllegalArgumentException( new AppEngException( "Someone tried to make all tiles movable with " + c + ", this is a clear violation of the purpose of the white list." ) ); } this.test.add( c ); diff --git a/src/main/java/appeng/core/sync/AppEngPacket.java b/src/main/java/appeng/core/sync/AppEngPacket.java index 4408efe9c..8fffb003c 100644 --- a/src/main/java/appeng/core/sync/AppEngPacket.java +++ b/src/main/java/appeng/core/sync/AppEngPacket.java @@ -40,7 +40,7 @@ public abstract class AppEngPacket public void serverPacketData( INetworkInfo manager, AppEngPacket packet, EntityPlayer player ) { - throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." ); + throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a server side handler." ); } public final int getPacketID() @@ -50,7 +50,7 @@ public abstract class AppEngPacket public void clientPacketData( INetworkInfo network, AppEngPacket packet, EntityPlayer player ) { - throw new RuntimeException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." ); + throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." ); } protected void configureWrite( ByteBuf data ) diff --git a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java index bae32029d..bbe8ddd81 100644 --- a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java +++ b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java @@ -130,7 +130,7 @@ public class AppEngPacketHandlerBase REVERSE_LOOKUP.put( this.packetClass, this ); if( this.packetConstructor == null ) - throw new RuntimeException( "Invalid Packet Class, must be constructable on DataInputStream" ); + throw new IllegalStateException( "Invalid Packet Class " + c + ", must be constructable on DataInputStream" ); } public static PacketTypes getPacket( int id ) diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index c71679998..4e26d5947 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -228,10 +228,10 @@ public enum GuiBridge implements IGuiHandler String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" ); if( start.equals( guiClass ) ) - throw new RuntimeException( "Unable to find gui class" ); + throw new IllegalStateException( "Unable to find gui class" ); this.Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass ); if( this.Gui == null ) - throw new RuntimeException( "Cannot Load class: " + guiClass ); + throw new IllegalStateException( "Cannot Load class: " + guiClass ); } } @@ -304,7 +304,7 @@ public enum GuiBridge implements IGuiHandler public boolean CorrectTileOrPart( Object tE ) { if( this.Tile == null ) - throw new RuntimeException( "This Gui Cannot use the standard Handler." ); + throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." ); return this.Tile.isInstance( tE ); } @@ -337,7 +337,7 @@ public enum GuiBridge implements IGuiHandler if( target == null ) { - throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" ); + throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" ); } Object o = target.newInstance( inventory, tE ); @@ -364,7 +364,7 @@ public enum GuiBridge implements IGuiHandler } catch( Throwable t ) { - throw new RuntimeException( t ); + throw new IllegalStateException( t ); } } @@ -462,14 +462,14 @@ public enum GuiBridge implements IGuiHandler if( target == null ) { - throw new RuntimeException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" ); + throw new IllegalStateException( "Cannot find " + this.Container.getName() + "( " + this.typeName( inventory ) + ", " + this.typeName( tE ) + " )" ); } return target.newInstance( inventory, tE ); } catch( Throwable t ) { - throw new RuntimeException( t ); + throw new IllegalStateException( t ); } } diff --git a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java index c9fc43d82..eb5827b31 100644 --- a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java @@ -67,7 +67,7 @@ public class PacketInventoryAction extends AppEngPacket { if( Platform.isClient() ) - throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." ); + throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." ); this.action = action; this.slot = slot; diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index a8f6a89bc..8d33fdf43 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -218,7 +218,7 @@ public class CraftingJob implements Runnable, ICraftingJob catch( Throwable t ) { this.finish(); - throw new RuntimeException( t ); + throw new IllegalStateException( t ); } this.finish(); diff --git a/src/main/java/appeng/crafting/CraftingLink.java b/src/main/java/appeng/crafting/CraftingLink.java index e677cfb6a..4f92ae61f 100644 --- a/src/main/java/appeng/crafting/CraftingLink.java +++ b/src/main/java/appeng/crafting/CraftingLink.java @@ -47,7 +47,7 @@ public class CraftingLink implements ICraftingLink this.standalone = data.getBoolean( "standalone" ); if( !data.hasKey( "req" ) || !data.getBoolean( "req" ) ) - throw new RuntimeException( "Invalid Crafting Link for Object" ); + throw new IllegalStateException( "Invalid Crafting Link for Object" ); this.req = req; this.cpu = null; @@ -61,7 +61,7 @@ public class CraftingLink implements ICraftingLink this.standalone = data.getBoolean( "standalone" ); if( !data.hasKey( "req" ) || data.getBoolean( "req" ) ) - throw new RuntimeException( "Invalid Crafting Link for Object" ); + throw new IllegalStateException( "Invalid Crafting Link for Object" ); this.cpu = cpu; this.req = null; diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index 55411309d..d8555c4d7 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -264,7 +264,7 @@ public class CraftingTreeProcess } } - throw new RuntimeException( "Crafting Tree construction failed." ); + throw new IllegalStateException( "Crafting Tree construction failed." ); } public void setSimulate() diff --git a/src/main/java/appeng/entity/EntityIds.java b/src/main/java/appeng/entity/EntityIds.java index fc89c804e..2951de70b 100644 --- a/src/main/java/appeng/entity/EntityIds.java +++ b/src/main/java/appeng/entity/EntityIds.java @@ -44,6 +44,6 @@ public final class EntityIds if( droppedEntity == EntityGrowingCrystal.class ) return GROWING_CRYSTAL; - throw new RuntimeException( "Missing entity id: " + droppedEntity.getName() ); + throw new IllegalStateException( "Missing entity id: " + droppedEntity.getName() ); } } diff --git a/src/main/java/appeng/facade/FacadePart.java b/src/main/java/appeng/facade/FacadePart.java index a8ba504d2..2f244a9f6 100644 --- a/src/main/java/appeng/facade/FacadePart.java +++ b/src/main/java/appeng/facade/FacadePart.java @@ -70,7 +70,7 @@ public class FacadePart implements IFacadePart, IBoxProvider public FacadePart( ItemStack facade, ForgeDirection side ) { if( facade == null ) - throw new RuntimeException( "Facade Part constructed on null item." ); + throw new IllegalArgumentException( "Facade Part constructed on null item." ); this.facade = facade.copy(); this.facade.stackSize = 1; this.side = side; diff --git a/src/main/java/appeng/fmp/PartRegistry.java b/src/main/java/appeng/fmp/PartRegistry.java index 452061d0d..4fbfb4e01 100644 --- a/src/main/java/appeng/fmp/PartRegistry.java +++ b/src/main/java/appeng/fmp/PartRegistry.java @@ -54,7 +54,8 @@ public enum PartRegistry return pr.name; } } - throw new RuntimeException( "Invalid PartName" ); + + throw new IllegalStateException( "Invalid PartName" ); } public static TMultiPart getPartByBlock( Block block, int meta ) @@ -80,7 +81,7 @@ public enum PartRegistry } catch( Throwable t ) { - throw new RuntimeException( t ); + throw new IllegalStateException( t ); } } diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 8f8479e80..392a4334f 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -598,7 +598,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn changed = true; ItemStack issue = adaptor.addItems( acquired.getItemStack() ); if( issue != null ) - throw new RuntimeException( "bad attempt at managing inventory. ( addItems )" ); + throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" ); } else changed = this.handleCrafting( x, adaptor, itemStack ) || changed; @@ -629,9 +629,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn changed = true; ItemStack removed = adaptor.removeItems( (int) diff, null, null ); if( removed == null ) - throw new RuntimeException( "bad attempt at managing inventory. ( removeItems )" ); + throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); else if( removed.stackSize != diff ) - throw new RuntimeException( "bad attempt at managing inventory. ( removeItems )" ); + throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); } } // else wtf? diff --git a/src/main/java/appeng/helpers/MetaRotation.java b/src/main/java/appeng/helpers/MetaRotation.java index c84784219..5cdf422cd 100644 --- a/src/main/java/appeng/helpers/MetaRotation.java +++ b/src/main/java/appeng/helpers/MetaRotation.java @@ -68,6 +68,6 @@ public class MetaRotation implements IOrientable if( this.w instanceof World ) ( (World) this.w ).setBlockMetadataWithNotify( this.x, this.y, this.z, Up.ordinal(), 1 + 2 ); else - throw new RuntimeException( this.w.getClass().getName() + " received, expected World" ); + throw new IllegalStateException( this.w.getClass().getName() + " received, expected World" ); } } diff --git a/src/main/java/appeng/helpers/PatternHelper.java b/src/main/java/appeng/helpers/PatternHelper.java index a32ca6b9f..bdf0894ca 100644 --- a/src/main/java/appeng/helpers/PatternHelper.java +++ b/src/main/java/appeng/helpers/PatternHelper.java @@ -65,7 +65,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable> extends MEMonitorHandler final NetworkMonitor last = DEPTH.pop(); if( last != this ) - throw new RuntimeException( "Invalid Access to Networked Storage API detected." ); + throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); } } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java index f7ce461df..6e8e98061 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java @@ -934,7 +934,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public IAEItemStack getItemStack( IAEItemStack what, CraftingItemList storage2 ) { - IAEItemStack is = null; + IAEItemStack is; switch( storage2 ) { case STORAGE: @@ -960,7 +960,7 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU break; default: case ALL: - throw new RuntimeException( "Invalid Operation" ); + throw new IllegalStateException( "Invalid Operation" ); } if( is != null ) diff --git a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java index 2ed87919c..0c035cf8a 100644 --- a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java +++ b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java @@ -168,7 +168,7 @@ public class NetworkInventoryHandler> implements IMEInvent private void surface( NetworkInventoryHandler networkInventoryHandler, Actionable type ) { if( this.getDepth( type ).pop() != this ) - throw new RuntimeException( "Invalid Access to Networked Storage API detected." ); + throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); } private LinkedList getDepth( Actionable type ) diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index 6d6cdf1f9..e542c8c11 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -348,7 +348,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I @Override public void clearContainer() { - throw new RuntimeException( "Now that is silly!" ); + throw new UnsupportedOperationException( "Now that is silly!" ); } @Override @@ -887,7 +887,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I p.readFromStream( data ); } else - throw new RuntimeException( "Invalid Stream For CableBus Container." ); + throw new IllegalStateException( "Invalid Stream For CableBus Container." ); } } else if( this.getPart( side ) != null ) @@ -936,7 +936,8 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I return side; } } - throw new RuntimeException( "Uhh Bad Part on Side." ); + + throw new IllegalStateException( "Uhh Bad Part (" + part + ") on Side." ); } public void readFromNBT( NBTTagCompound data ) diff --git a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java index b74ecba29..027a56590 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java @@ -117,7 +117,7 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl if( requestTotal <= 0 ) { if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return 0; } @@ -125,7 +125,7 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl if( !doFill ) { if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return Math.min( resource.amount, requestTotal ); } @@ -154,7 +154,7 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl } if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return used; } diff --git a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java index 8d19a07cf..aec3cec57 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java @@ -130,7 +130,7 @@ public class PartP2PRFPower extends PartP2PTunnel implements IEn } if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return total; } @@ -197,7 +197,7 @@ public class PartP2PRFPower extends PartP2PTunnel implements IEn } if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return total; } @@ -231,7 +231,7 @@ public class PartP2PRFPower extends PartP2PTunnel implements IEn } if( stack.pop() != this ) - throw new RuntimeException( "Invalid Recursion detected." ); + throw new IllegalStateException( "Invalid Recursion detected." ); return total; } diff --git a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java index bf2cc2341..0f004275d 100644 --- a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java @@ -229,8 +229,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit this.dspList = GLAllocation.generateDisplayLists( 1 ); Tessellator tess = Tessellator.instance; - if( Platform.isDrawing( tess ) ) - return; if( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) return; diff --git a/src/main/java/appeng/recipes/RecipeHandler.java b/src/main/java/appeng/recipes/RecipeHandler.java index 491ef0c78..c516186ee 100644 --- a/src/main/java/appeng/recipes/RecipeHandler.java +++ b/src/main/java/appeng/recipes/RecipeHandler.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.Map.Entry; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; - import javax.annotation.Nonnull; import net.minecraft.item.Item; @@ -324,7 +323,7 @@ public class RecipeHandler implements IRecipeHandler { AELog.error( e ); if( this.data.crash ) - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } @@ -332,7 +331,7 @@ public class RecipeHandler implements IRecipeHandler public void injectRecipes() { if( cpw.mods.fml.common.Loader.instance().hasReachedState( LoaderState.POSTINITIALIZATION ) ) - throw new RuntimeException( "Recipes must now be loaded in Init." ); + throw new IllegalStateException( "Recipes must now be loaded in Init." ); HashMap processed = new HashMap(); try @@ -376,7 +375,7 @@ public class RecipeHandler implements IRecipeHandler if( this.data.exceptions ) AELog.error( e ); if( this.data.crash ) - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } for( Entry e : processed.entrySet() ) diff --git a/src/main/java/appeng/recipes/game/ShapedRecipe.java b/src/main/java/appeng/recipes/game/ShapedRecipe.java index b9d3387fc..8ae18fa8f 100644 --- a/src/main/java/appeng/recipes/game/ShapedRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapedRecipe.java @@ -100,7 +100,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable ret.append( tmp ).append( ", " ); } ret.append( this.output ); - throw new RuntimeException( ret.toString() ); + throw new IllegalStateException( ret.toString() ); } HashMap itemMap = new HashMap(); @@ -122,7 +122,7 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable ret.append( tmp ).append( ", " ); } ret.append( this.output ); - throw new RuntimeException( ret.toString() ); + throw new IllegalStateException( ret.toString() ); } } diff --git a/src/main/java/appeng/recipes/game/ShapelessRecipe.java b/src/main/java/appeng/recipes/game/ShapelessRecipe.java index 3ff832e0b..8b7fcdb40 100644 --- a/src/main/java/appeng/recipes/game/ShapelessRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapelessRecipe.java @@ -56,7 +56,7 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable ret.append( tmp ).append( ", " ); } ret.append( this.output ); - throw new RuntimeException( ret.toString() ); + throw new IllegalArgumentException( ret.toString() ); } } } diff --git a/src/main/java/appeng/recipes/handlers/MekCrusher.java b/src/main/java/appeng/recipes/handlers/MekCrusher.java index f1b6ac479..465e986d2 100644 --- a/src/main/java/appeng/recipes/handlers/MekCrusher.java +++ b/src/main/java/appeng/recipes/handlers/MekCrusher.java @@ -55,6 +55,7 @@ public class MekCrusher implements ICraftHandler, IWebsiteSerializer return; } } + throw new RecipeError( "MekCrusher must have a single input, and single output." ); } diff --git a/src/main/java/appeng/server/AECommand.java b/src/main/java/appeng/server/AECommand.java index 60cd60912..539f92631 100644 --- a/src/main/java/appeng/server/AECommand.java +++ b/src/main/java/appeng/server/AECommand.java @@ -27,10 +27,9 @@ import net.minecraft.server.MinecraftServer; import com.google.common.base.Joiner; -public class AECommand extends CommandBase +public final class AECommand extends CommandBase { - - final MinecraftServer srv; + private final MinecraftServer srv; public AECommand( MinecraftServer server ) { diff --git a/src/main/java/appeng/server/ServerHelper.java b/src/main/java/appeng/server/ServerHelper.java index 4d7585161..c21b0f082 100644 --- a/src/main/java/appeng/server/ServerHelper.java +++ b/src/main/java/appeng/server/ServerHelper.java @@ -58,13 +58,13 @@ public class ServerHelper extends CommonHelper @Override public World getWorld() { - throw new RuntimeException( "This is a server..." ); + throw new UnsupportedOperationException( "This is a server..." ); } @Override public void bindTileEntitySpecialRenderer( Class tile, AEBaseBlock blk ) { - throw new RuntimeException( "This is a server..." ); + throw new UnsupportedOperationException( "This is a server..." ); } @Override @@ -179,6 +179,6 @@ public class ServerHelper extends CommonHelper @Override public void missingCoreMod() { - throw new RuntimeException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." ); + throw new IllegalStateException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." ); } } diff --git a/src/main/java/appeng/services/version/VersionParser.java b/src/main/java/appeng/services/version/VersionParser.java index b1dbc6449..d872f937a 100644 --- a/src/main/java/appeng/services/version/VersionParser.java +++ b/src/main/java/appeng/services/version/VersionParser.java @@ -1,7 +1,6 @@ package appeng.services.version; -import java.security.InvalidParameterException; import java.util.Scanner; import java.util.regex.Pattern; @@ -111,7 +110,7 @@ public final class VersionParser } } - throw new InvalidParameterException( "Raw channel did not contain any of the pre-programmed types." ); + throw new IllegalArgumentException( "Raw channel " + rawChannel + " did not contain any of the pre-programmed types." ); } /** diff --git a/src/main/java/appeng/tile/crafting/TileCraftingTile.java b/src/main/java/appeng/tile/crafting/TileCraftingTile.java index 5a691eb9c..1e7421a02 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingTile.java @@ -269,7 +269,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP Collections.shuffle( places ); if( places.isEmpty() ) - throw new RuntimeException( "No air or even the tile hat was destroyed?!?!" ); + throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." ); for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) ) { diff --git a/src/main/java/appeng/tile/events/AETileEventHandler.java b/src/main/java/appeng/tile/events/AETileEventHandler.java index abac907ba..d33b25519 100644 --- a/src/main/java/appeng/tile/events/AETileEventHandler.java +++ b/src/main/java/appeng/tile/events/AETileEventHandler.java @@ -51,15 +51,15 @@ public class AETileEventHandler } catch( IllegalAccessException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( IllegalArgumentException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( InvocationTargetException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } @@ -72,15 +72,15 @@ public class AETileEventHandler } catch( IllegalAccessException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( IllegalArgumentException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( InvocationTargetException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } @@ -93,15 +93,15 @@ public class AETileEventHandler } catch( IllegalAccessException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( IllegalArgumentException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( InvocationTargetException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } @@ -114,15 +114,15 @@ public class AETileEventHandler } catch( IllegalAccessException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( IllegalArgumentException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( InvocationTargetException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } @@ -144,15 +144,15 @@ public class AETileEventHandler } catch( IllegalAccessException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( IllegalArgumentException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } catch( InvocationTargetException e ) { - throw new RuntimeException( e ); + throw new IllegalStateException( e ); } } } diff --git a/src/main/java/appeng/tile/storage/TileChest.java b/src/main/java/appeng/tile/storage/TileChest.java index d6834215d..64fe50d3f 100644 --- a/src/main/java/appeng/tile/storage/TileChest.java +++ b/src/main/java/appeng/tile/storage/TileChest.java @@ -785,7 +785,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan private static class ChestNoHandler extends Exception { - private static final long serialVersionUID = 7995805326136526631L; } diff --git a/src/main/java/appeng/transformer/MissingCoreMod.java b/src/main/java/appeng/transformer/MissingCoreMod.java index 4f112cc57..d09b771ae 100644 --- a/src/main/java/appeng/transformer/MissingCoreMod.java +++ b/src/main/java/appeng/transformer/MissingCoreMod.java @@ -23,18 +23,24 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiErrorScreen; import cpw.mods.fml.client.CustomModLoadingErrorDisplayException; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class MissingCoreMod extends CustomModLoadingErrorDisplayException +@SideOnly( Side.CLIENT ) +public final class MissingCoreMod extends CustomModLoadingErrorDisplayException { - + private static final int SHADOW_WHITE = 0xeeeeee; + private static final int COLOR_WHITE = 0xffffff; private static final long serialVersionUID = -966774766922821652L; + private static final int SCREEN_OFFSET = 15; + private boolean deobf = false; @Override public void initGui( GuiErrorScreen errorScreen, FontRenderer fontRenderer ) { - Class clz = errorScreen.getClass(); + Class clz = errorScreen.getClass(); try { clz.getField( "mc" ); @@ -50,35 +56,46 @@ public class MissingCoreMod extends CustomModLoadingErrorDisplayException public void drawScreen( GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime ) { int offset = 10; - this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 Properly.", errorScreen.width / 2, offset += 15, 0xffffff ); - this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset += 15, 0xeeeeee ); + this.drawCenteredString( fontRenderer, "Sorry, couldn't load AE2 properly.", errorScreen.width / 2, offset, COLOR_WHITE ); - offset += 15; + offset += SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "Please make sure that AE2 is installed into your mods folder.", errorScreen.width / 2, offset, SHADOW_WHITE ); + + offset += 2 * SCREEN_OFFSET; if( this.deobf ) { - offset += 15; - this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset += 15, 0xffffff ); - this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.transformer.AppEngCore", errorScreen.width / 2, offset += 15, 0xeeeeee ); + offset += SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "In a developer environment add the following too your args,", errorScreen.width / 2, offset, COLOR_WHITE ); + + offset += SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "-Dfml.coreMods.load=appeng.transformer.AppEngCore", errorScreen.width / 2, offset, SHADOW_WHITE ); } else { - this.drawCenteredString( fontRenderer, "You're launcher may refer to this by different names,", errorScreen.width / 2, offset += 15, 0xffffff ); + this.drawCenteredString( fontRenderer, "You're launcher may refer to this by different names,", errorScreen.width / 2, offset, COLOR_WHITE ); - offset += 5; + offset += SCREEN_OFFSET + 5; - this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); - this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); - this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset += 15, 0xeeeeee ); + this.drawCenteredString( fontRenderer, "MultiMC calls this tab \"Loader Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE ); - offset += 15; + offset += SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "Magic Launcher calls this tab \"External Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE ); - this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset += 15, 0xffffff ); + offset += SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "Most other launchers refer to this tab as just \"Mods\"", errorScreen.width / 2, offset, SHADOW_WHITE ); + + offset += 2 * SCREEN_OFFSET; + this.drawCenteredString( fontRenderer, "Also make sure that the AE2 file is a .jar, and not a .zip", errorScreen.width / 2, offset, COLOR_WHITE ); } } - public void drawCenteredString( FontRenderer fontRenderer, String string, int x, int y, int colour ) + private void drawCenteredString( FontRenderer fontRenderer, String string, int x, int y, int colour ) { - fontRenderer.drawStringWithShadow( string, x - fontRenderer.getStringWidth( string.replaceAll( "\\P{InBasic_Latin}", "" ) ) / 2, y, colour ); + final String reEncoded = string.replaceAll( "\\P{InBasic_Latin}", "" ); + final int reEndcodedWidth = fontRenderer.getStringWidth( reEncoded ); + final int centeredX = x - reEndcodedWidth / 2; + + fontRenderer.drawStringWithShadow( string, centeredX, y, colour ); } } \ No newline at end of file diff --git a/src/main/java/appeng/transformer/asm/ASMIntegration.java b/src/main/java/appeng/transformer/asm/ASMIntegration.java index 7326fe4b3..3b760f236 100644 --- a/src/main/java/appeng/transformer/asm/ASMIntegration.java +++ b/src/main/java/appeng/transformer/asm/ASMIntegration.java @@ -153,7 +153,7 @@ public class ASMIntegration implements IClassTransformer private boolean stripInterface( ClassNode classNode, Class class1, AnnotationNode an ) { if( an.values.size() != 4 ) - throw new RuntimeException( "Unable to handle Interface annotation on " + classNode.name ); + throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name ); String iFace = null; String iName = null; @@ -182,7 +182,7 @@ public class ASMIntegration implements IClassTransformer this.log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." ); } else - throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name ); + throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name ); return false; } @@ -190,7 +190,7 @@ public class ASMIntegration implements IClassTransformer private boolean stripMethod( ClassNode classNode, MethodNode mn, Iterator i, Class class1, AnnotationNode an ) { if( an.values.size() != 2 ) - throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name ); + throw new IllegalArgumentException( "Unable to handle Method annotation on " + classNode.name ); String iName = null; @@ -210,7 +210,7 @@ public class ASMIntegration implements IClassTransformer this.log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." ); } else - throw new RuntimeException( "Unable to handle Method annotation on " + classNode.name ); + throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name ); return false; } diff --git a/src/main/java/appeng/util/ConfigManager.java b/src/main/java/appeng/util/ConfigManager.java index 450e79ed1..65f3a8c20 100644 --- a/src/main/java/appeng/util/ConfigManager.java +++ b/src/main/java/appeng/util/ConfigManager.java @@ -62,7 +62,7 @@ public final class ConfigManager implements IConfigManager if( oldValue != null ) return oldValue; - throw new RuntimeException( "Invalid Config setting" ); + throw new IllegalStateException( "Invalid Config setting. Expected a non-null value for " + settingName ); } @Override diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index d518a0f04..275daf25d 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -21,6 +21,7 @@ package appeng.util; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.security.InvalidParameterException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collection; @@ -31,13 +32,11 @@ import java.util.List; import java.util.Random; import java.util.Set; import java.util.WeakHashMap; - -import javax.annotation.Nullable; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -951,7 +950,7 @@ public class Platform public static EntityPlayer getPlayer( WorldServer w ) { if( w == null ) - throw new NullPointerException(); + throw new InvalidParameterException( "World is null." ); EntityPlayer wrp = FAKE_PLAYERS.get( w ); if( wrp != null ) @@ -1578,11 +1577,6 @@ public class Platform return !gs.hasPermission( playerID, SecurityPermissions.BUILD ); } - public static boolean isDrawing( Tessellator tess ) - { - return false; - } - public static void configurePlayer( EntityPlayer player, ForgeDirection side, TileEntity tile ) { float pitch = 0.0f; diff --git a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java index 959e3a69a..c22092a08 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java +++ b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java @@ -25,15 +25,15 @@ import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; -public class IMEAdaptorIterator implements Iterator +public final class IMEAdaptorIterator implements Iterator { + private final Iterator stack; + private final ItemSlot slot = new ItemSlot(); + private final IMEAdaptor parent; + private final int containerSize; - final Iterator stack; - final ItemSlot slot = new ItemSlot(); - final IMEAdaptor parent; - final int containerSize; - int offset = 0; - boolean hasNext; + private int offset = 0; + private boolean hasNext; public IMEAdaptorIterator( IMEAdaptor parent, IItemList availableItems ) { @@ -73,6 +73,6 @@ public class IMEAdaptorIterator implements Iterator @Override public void remove() { - throw new RuntimeException( "Not Implemented!" ); + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/appeng/util/item/AEFluidStack.java b/src/main/java/appeng/util/item/AEFluidStack.java index 1beee7ece..b845d8ddd 100644 --- a/src/main/java/appeng/util/item/AEFluidStack.java +++ b/src/main/java/appeng/util/item/AEFluidStack.java @@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import javax.annotation.Nonnull; import io.netty.buffer.ByteBuf; @@ -60,15 +61,12 @@ public final class AEFluidStack extends AEStack implements IAEFlu this.myHash = is.myHash; } - private AEFluidStack( FluidStack is ) + private AEFluidStack( @Nonnull FluidStack is ) { - if( is == null ) - throw new RuntimeException( "Invalid Itemstack." ); - this.fluid = is.getFluid(); if( this.fluid == null ) - throw new RuntimeException( "Fluid is null." ); + throw new IllegalArgumentException( "Fluid is null." ); this.stackSize = is.amount; this.setCraftable( false ); diff --git a/src/main/java/appeng/util/item/ItemList.java b/src/main/java/appeng/util/item/ItemList.java index baaa4eedc..bcf1e3470 100644 --- a/src/main/java/appeng/util/item/ItemList.java +++ b/src/main/java/appeng/util/item/ItemList.java @@ -79,7 +79,7 @@ public final class ItemList implements IItemList +public final class AEInvIterator implements Iterator { + private final AppEngInternalAEInventory inventory; + private final int size; - final AppEngInternalAEInventory inv; - final int size; + private int counter = 0; - int x = 0; - - public AEInvIterator( AppEngInternalAEInventory i ) + public AEInvIterator( AppEngInternalAEInventory inventory ) { - this.inv = i; - this.size = this.inv.getSizeInventory(); + this.inventory = inventory; + this.size = this.inventory.getSizeInventory(); } @Override public boolean hasNext() { - return this.x < this.size; + return this.counter < this.size; } @Override public IAEItemStack next() { - IAEItemStack result = this.inv.getAEStackInSlot( this.x ); - this.x++; + final IAEItemStack result = this.inventory.getAEStackInSlot( this.counter ); + + this.counter++; + return result; } @Override public void remove() { - throw new RuntimeException( "no..." ); + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/appeng/util/iterators/ChainedIterator.java b/src/main/java/appeng/util/iterators/ChainedIterator.java index 6cbb82660..6134d1f1e 100644 --- a/src/main/java/appeng/util/iterators/ChainedIterator.java +++ b/src/main/java/appeng/util/iterators/ChainedIterator.java @@ -22,11 +22,11 @@ package appeng.util.iterators; import java.util.Iterator; -public class ChainedIterator implements Iterator +public final class ChainedIterator implements Iterator { + private final T[] list; - final T[] list; - int offset = 0; + private int offset = 0; public ChainedIterator( T... list ) { @@ -50,6 +50,6 @@ public class ChainedIterator implements Iterator @Override public void remove() { - throw new RuntimeException( "Not implemented." ); + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/appeng/util/iterators/InvIterator.java b/src/main/java/appeng/util/iterators/InvIterator.java index e27004f35..92eb8a17d 100644 --- a/src/main/java/appeng/util/iterators/InvIterator.java +++ b/src/main/java/appeng/util/iterators/InvIterator.java @@ -25,37 +25,37 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -public class InvIterator implements Iterator +public final class InvIterator implements Iterator { + private final IInventory inventory; + private final int size; - final IInventory inv; - final int size; + private int counter = 0; - int x = 0; - - public InvIterator( IInventory i ) + public InvIterator( IInventory inventory ) { - this.inv = i; - this.size = this.inv.getSizeInventory(); + this.inventory = inventory; + this.size = this.inventory.getSizeInventory(); } @Override public boolean hasNext() { - return this.x < this.size; + return this.counter < this.size; } @Override public ItemStack next() { - ItemStack result = this.inv.getStackInSlot( this.x ); - this.x++; + ItemStack result = this.inventory.getStackInSlot( this.counter ); + this.counter++; + return result; } @Override public void remove() { - throw new RuntimeException( "no..." ); + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/appeng/util/iterators/ProxyNodeIterator.java b/src/main/java/appeng/util/iterators/ProxyNodeIterator.java index dc8b8f956..559ea3441 100644 --- a/src/main/java/appeng/util/iterators/ProxyNodeIterator.java +++ b/src/main/java/appeng/util/iterators/ProxyNodeIterator.java @@ -27,10 +27,9 @@ import appeng.api.networking.IGridHost; import appeng.api.networking.IGridNode; -public class ProxyNodeIterator implements Iterator +public final class ProxyNodeIterator implements Iterator { - - final Iterator hosts; + private final Iterator hosts; public ProxyNodeIterator( Iterator hosts ) { @@ -53,6 +52,6 @@ public class ProxyNodeIterator implements Iterator @Override public void remove() { - throw new RuntimeException( "Not implemented." ); + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/appeng/util/prioitylist/IPartitionList.java b/src/main/java/appeng/util/prioitylist/IPartitionList.java index 2981f0918..95b27d4a1 100644 --- a/src/main/java/appeng/util/prioitylist/IPartitionList.java +++ b/src/main/java/appeng/util/prioitylist/IPartitionList.java @@ -24,7 +24,6 @@ import appeng.api.storage.data.IAEStack; public interface IPartitionList> { - boolean isListed( T input ); boolean isEmpty(); diff --git a/src/main/java/appeng/util/prioitylist/MergedPriorityList.java b/src/main/java/appeng/util/prioitylist/MergedPriorityList.java index 4eed91c6c..5a1623034 100644 --- a/src/main/java/appeng/util/prioitylist/MergedPriorityList.java +++ b/src/main/java/appeng/util/prioitylist/MergedPriorityList.java @@ -20,16 +20,16 @@ package appeng.util.prioitylist; import java.util.ArrayList; -import java.util.List; +import java.util.Collection; import appeng.api.storage.data.IAEStack; -public class MergedPriorityList> implements IPartitionList +public final class MergedPriorityList> implements IPartitionList { - final List> positive = new ArrayList>(); - final List> negative = new ArrayList>(); + private final Collection> positive = new ArrayList>(); + private final Collection> negative = new ArrayList>(); public void addNewList( IPartitionList list, boolean isWhitelist ) { @@ -67,6 +67,6 @@ public class MergedPriorityList> implements IPartitionList @Override public Iterable getItems() { - throw new RuntimeException( "Not Implemented" ); + throw new UnsupportedOperationException(); } }