Merge pull request #207 from SquidDev-CC/feature/cleanup

Fix a couple of warnings
This commit is contained in:
Daniel Ratcliffe
2017-05-07 18:26:07 +01:00
committed by GitHub
225 changed files with 1656 additions and 1317 deletions
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -37,7 +37,7 @@ public enum Colour
private int m_hex;
private float[] m_rgb;
private Colour( int hex )
Colour( int hex )
{
m_hex = hex;
m_rgb = new float[] {
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -10,6 +10,8 @@ import dan200.computercraft.ComputerCraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import javax.annotation.Nonnull;
public class CreativeTabMain extends CreativeTabs
{
public CreativeTabMain( int i )
@@ -17,12 +19,14 @@ public class CreativeTabMain extends CreativeTabs
super( i, "ComputerCraft" );
}
@Nonnull
@Override
public Item getTabIconItem()
{
return Item.getItemFromBlock( ComputerCraft.Blocks.computer );
}
@Nonnull
@Override
public String getTranslatedTabLabel()
{
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -10,6 +10,8 @@ import dan200.computercraft.ComputerCraft;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import javax.annotation.Nonnull;
public class CreativeTabTreasure extends CreativeTabs
{
public CreativeTabTreasure( int i )
@@ -17,12 +19,14 @@ public class CreativeTabTreasure extends CreativeTabs
super( i, "Treasure Disks" );
}
@Nonnull
@Override
public Item getTabIconItem()
{
return ComputerCraft.Items.treasureDisk;
}
@Nonnull
@Override
public String getTranslatedTabLabel()
{
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -21,7 +21,7 @@ public class IDAssigner
private static int getNextID( File location, boolean directory )
{
// Determine where to locate ID file
File lastidFile = null;
File lastidFile;
if( directory )
{
location.mkdirs();
@@ -41,13 +41,15 @@ public class IDAssigner
if( directory && location.exists() && location.isDirectory() )
{
String[] contents = location.list();
for( int i=0; i<contents.length; ++i )
for( String content : contents )
{
try {
int number = Integer.parseInt( contents[i] );
try
{
int number = Integer.parseInt( content );
id = Math.max( number + 1, id );
} catch( NumberFormatException e ) {
continue;
}
catch( NumberFormatException e )
{
}
}
}
@@ -55,7 +57,7 @@ public class IDAssigner
else
{
// If an ID file does exist, parse the file to get the ID string
String idString = "0";
String idString;
try
{
FileInputStream in = new FileInputStream( lastidFile );
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -10,5 +10,5 @@ import net.minecraft.item.ItemStack;
public interface IEntityDropConsumer
{
public void consumeDrop( Entity dropper, ItemStack drop );
void consumeDrop( Entity dropper, ItemStack drop );
}
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -10,6 +10,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class ImpostorRecipe extends ShapedRecipes
{
public ImpostorRecipe( int width, int height, ItemStack[] ingredients, ItemStack result )
@@ -18,13 +20,13 @@ public class ImpostorRecipe extends ShapedRecipes
}
@Override
public boolean matches( InventoryCrafting inv, World world )
public boolean matches( @Nonnull InventoryCrafting inv, World world )
{
return false;
}
@Override
public ItemStack getCraftingResult( InventoryCrafting _inventory )
public ItemStack getCraftingResult( @Nonnull InventoryCrafting _inventory )
{
return null;
}
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -16,9 +16,9 @@ import java.util.Arrays;
public class ImpostorShapelessRecipe extends ShapelessRecipes
{
public ImpostorShapelessRecipe( ItemStack result, Object[] ingredients )
public ImpostorShapelessRecipe( ItemStack result, ItemStack[] ingredients )
{
super( result, new ArrayList(Arrays.asList( ingredients )));
super( result, new ArrayList<ItemStack>(Arrays.asList( ingredients )));
}
@Override
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -206,12 +206,11 @@ public class InventoryUtil
// Inspect the slots in order and try to find empty or stackable slots
ItemStack remainder = stack;
for( int n=0; n<slots.length; ++n )
for( int slot : slots )
{
int slot = slots[n];
if( canPlaceItemThroughFace( inventory, slot, remainder, face ) )
{
ItemStack slotContents = inventory.getStackInSlot(slot);
ItemStack slotContents = inventory.getStackInSlot( slot );
if( slotContents == null )
{
// Slot is empty
@@ -286,9 +285,8 @@ public class InventoryUtil
// Combine multiple stacks from inventory into one if necessary
ItemStack partialStack = null;
int countRemaining = count;
for( int n=0; n<slots.length; ++n )
for( int slot : slots )
{
int slot = slots[n];
if( countRemaining > 0 )
{
ItemStack stack = inventory.getStackInSlot( slot );
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -20,7 +20,7 @@ public class NBTUtil
{
if( object instanceof Boolean )
{
boolean b = ((Boolean)object).booleanValue();
boolean b = (Boolean) object;
return new NBTTagByte( b ? (byte)1 : (byte)0 );
}
else if( object instanceof Number )
@@ -35,10 +35,10 @@ public class NBTUtil
}
else if( object instanceof Map )
{
Map<Object, Object> m = (Map<Object, Object>)object;
Map<?, ?> m = (Map<?, ?>)object;
NBTTagCompound nbt = new NBTTagCompound();
int i=0;
for( Map.Entry<Object, Object> entry : m.entrySet() )
for( Map.Entry<?, ?> entry : m.entrySet() )
{
NBTBase key = toNBTTag( entry.getKey() );
NBTBase value = toNBTTag( entry.getKey() );
@@ -85,18 +85,15 @@ public class NBTUtil
{
case Constants.NBT.TAG_BYTE: // byte
{
boolean b = (((NBTTagByte)tag).getByte() > 0);
return b;
return (((NBTTagByte)tag).getByte() > 0);
}
case Constants.NBT.TAG_DOUBLE: // Double
{
double d = ((NBTTagDouble)tag).getDouble();
return d;
return ((NBTTagDouble)tag).getDouble();
}
case Constants.NBT.TAG_STRING: // String
{
String s = ((NBTTagString)tag).getString();
return s;
return ((NBTTagString)tag).getString();
}
case Constants.NBT.TAG_COMPOUND: // Compound
{
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -13,7 +13,7 @@ import java.lang.reflect.Modifier;
public class ReflectionUtil
{
public static Class getOptionalClass( String name )
public static Class<?> getOptionalClass( String name )
{
try
{
@@ -26,20 +26,20 @@ public class ReflectionUtil
return null;
}
public static Class getOptionalInnerClass( Class enclosingClass, String name )
public static Class<?> getOptionalInnerClass( Class<?> enclosingClass, String name )
{
if( enclosingClass != null )
{
try
{
Class[] declaredClasses = enclosingClass.getDeclaredClasses();
Class<?>[] declaredClasses = enclosingClass.getDeclaredClasses();
if( declaredClasses != null )
{
for( int i=0; i<declaredClasses.length; ++i )
for( Class<?> declaredClass : declaredClasses )
{
if( declaredClasses[i].getSimpleName().equals( name ) )
if( declaredClass.getSimpleName().equals( name ) )
{
return declaredClasses[i];
return declaredClass;
}
}
}
@@ -52,7 +52,7 @@ public class ReflectionUtil
return null;
}
public static Method getOptionalMethod( Class clazz, String name, Class[] arguments )
public static Method getOptionalMethod( Class<?> clazz, String name, Class<?>[] arguments )
{
if( clazz != null )
{
@@ -68,7 +68,7 @@ public class ReflectionUtil
return null;
}
public static Constructor getOptionalConstructor( Class clazz, Class[] arguments )
public static <T> Constructor<T> getOptionalConstructor( Class<T> clazz, Class<?>[] arguments )
{
if( clazz != null )
{
@@ -84,7 +84,7 @@ public class ReflectionUtil
return null;
}
public static Field getOptionalField( Class clazz, String name )
public static Field getOptionalField( Class<?> clazz, String name )
{
if( clazz != null )
{
@@ -97,7 +97,7 @@ public class ReflectionUtil
{
field.setAccessible( true );
}
catch( Exception e )
catch( Exception ignored )
{
}
}
@@ -111,16 +111,16 @@ public class ReflectionUtil
return null;
}
public static <T> T safeNew( Constructor constructor, Object[] arguments, Class<T> resultClass )
public static <T> T safeNew( Constructor<T> constructor, Object[] arguments, Class<T> resultClass )
{
if( constructor != null )
{
try
{
Object result = constructor.newInstance( arguments );
T result = constructor.newInstance( arguments );
if( result != null && resultClass.isInstance( result ) )
{
return (T)result;
return result;
}
}
catch( Exception e )
@@ -131,7 +131,7 @@ public class ReflectionUtil
return null;
}
public static boolean safeInstanceOf( Object object, Class clazz )
public static boolean safeInstanceOf( Object object, Class<?> clazz )
{
if( clazz != null )
{
@@ -158,6 +158,7 @@ public class ReflectionUtil
}
}
@SuppressWarnings("unchecked")
public static <T> T safeInvoke( Method method, Object object, Object[] arguments, Class<T> resultClass )
{
if( method != null )
@@ -182,6 +183,7 @@ public class ReflectionUtil
return null;
}
@SuppressWarnings("unchecked")
public static <T> T safeGet( Field field, Object object, Class<T> resultClass )
{
if( field != null )
@@ -1,4 +1,4 @@
/**
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
@@ -6,8 +6,6 @@
package dan200.computercraft.shared.util;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
@@ -62,10 +60,9 @@ public class WorldUtil
Entity closest = null;
double closestDist = 99.0;
List list = world.getEntitiesWithinAABBExcludingEntity( null, bigBox );
for( int i=0; i<list.size(); i++ )
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity( null, bigBox );
for( Entity entity : list )
{
Entity entity = (net.minecraft.entity.Entity)list.get(i);
if( entity.isDead || !entity.canBeCollidedWith() )
{
continue;