1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-17 10:50:01 +00:00

Fix some warnings (#235)

Remove some unused code and fix a bunch of warnings
This commit is contained in:
Lignum 2019-06-07 15:35:17 +02:00 committed by SquidDev
parent 00c395f689
commit 7d428030df
16 changed files with 19 additions and 38 deletions

6
.gitignore vendored
View File

@ -15,3 +15,9 @@
.idea .idea
.gradle .gradle
*.DS_Store *.DS_Store
.classpath
.project
.settings/
bin/
*.launch

View File

@ -90,7 +90,6 @@ public interface IMount
* @throws IOException If the file does not exist, or could not be opened. * @throws IOException If the file does not exist, or could not be opened.
*/ */
@Nonnull @Nonnull
@SuppressWarnings( "deprecation" )
default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForRead( path ) ); return Channels.newChannel( openForRead( path ) );

View File

@ -67,7 +67,6 @@ public interface IWritableMount extends IMount
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
@Nonnull @Nonnull
@SuppressWarnings( "deprecation" )
default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForWrite( path ) ); return Channels.newChannel( openForWrite( path ) );
@ -94,7 +93,6 @@ default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws I
* @throws IOException If the file could not be opened for writing. * @throws IOException If the file could not be opened for writing.
*/ */
@Nonnull @Nonnull
@SuppressWarnings( "deprecation" )
default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException
{ {
return Channels.newChannel( openForAppend( path ) ); return Channels.newChannel( openForAppend( path ) );

View File

@ -83,6 +83,7 @@ public String[] getMethodNames()
} }
@Override @Override
@SuppressWarnings( "resource" )
public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException
{ {
switch( method ) switch( method )
@ -95,7 +96,7 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
if( args.length >= 1 && args[0] instanceof Map ) if( args.length >= 1 && args[0] instanceof Map )
{ {
Map<?, ?> options = (Map) args[0]; Map<?, ?> options = (Map<?, ?>) args[0];
address = getStringField( options, "url" ); address = getStringField( options, "url" );
postString = optStringField( options, "body", null ); postString = optStringField( options, "body", null );
headerTable = optTableField( options, "headers", Collections.emptyMap() ); headerTable = optTableField( options, "headers", Collections.emptyMap() );
@ -135,7 +136,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
try try
{ {
URI uri = HttpRequest.checkUri( address ); URI uri = HttpRequest.checkUri( address );
HttpRequest request = new HttpRequest( requests, m_apiEnvironment, address, postString, headers, binary, redirect ); HttpRequest request = new HttpRequest( requests, m_apiEnvironment, address, postString, headers, binary, redirect );
long requestBody = request.body().readableBytes() + HttpRequest.getHeaderSize( headers ); long requestBody = request.body().readableBytes() + HttpRequest.getHeaderSize( headers );

View File

@ -401,7 +401,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
Instant instant = Instant.ofEpochSecond( time ); Instant instant = Instant.ofEpochSecond( time );
ZonedDateTime date; ZonedDateTime date;
ZoneOffset offset; ZoneOffset offset;
boolean isDst;
if( format.startsWith( "!" ) ) if( format.startsWith( "!" ) )
{ {
offset = ZoneOffset.UTC; offset = ZoneOffset.UTC;

View File

@ -356,7 +356,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O
ComputerSide side = ComputerSide.valueOfInsensitive( getString( args, 0 ) ); ComputerSide side = ComputerSide.valueOfInsensitive( getString( args, 0 ) );
if( side != null ) if( side != null )
{ {
String type = null;
synchronized( m_peripherals ) synchronized( m_peripherals )
{ {
PeripheralWrapper p = m_peripherals[side.ordinal()]; PeripheralWrapper p = m_peripherals[side.ordinal()];

View File

@ -239,7 +239,6 @@ public void addAPI( dan200.computercraft.core.apis.ILuaAPI api )
} }
@Deprecated @Deprecated
@SuppressWarnings( "unused" )
public void advance( double dt ) public void advance( double dt )
{ {
tick(); tick();

View File

@ -93,7 +93,7 @@ public JarMount( File jarFile, String subPath ) throws IOException
new MountReference( this ); new MountReference( this );
// Read in all the entries // Read in all the entries
root = new FileEntry( "" ); root = new FileEntry();
Enumeration<? extends ZipEntry> zipEntries = zip.entries(); Enumeration<? extends ZipEntry> zipEntries = zip.entries();
while( zipEntries.hasMoreElements() ) while( zipEntries.hasMoreElements() )
{ {
@ -140,7 +140,7 @@ private void create( ZipEntry entry, String localPath )
FileEntry nextEntry = lastEntry.children.get( part ); FileEntry nextEntry = lastEntry.children.get( part );
if( nextEntry == null || !nextEntry.isDirectory() ) if( nextEntry == null || !nextEntry.isDirectory() )
{ {
lastEntry.children.put( part, nextEntry = new FileEntry( part ) ); lastEntry.children.put( part, nextEntry = new FileEntry() );
} }
lastEntry = nextEntry; lastEntry = nextEntry;
@ -224,17 +224,10 @@ public ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOE
private static class FileEntry private static class FileEntry
{ {
final String name;
String path; String path;
long size; long size;
Map<String, FileEntry> children; Map<String, FileEntry> children;
FileEntry( String name )
{
this.name = name;
}
void setup( ZipEntry entry ) void setup( ZipEntry entry )
{ {
path = entry.getName(); path = entry.getName();

View File

@ -51,7 +51,6 @@ public final boolean onBlockActivated( World world, BlockPos pos, IBlockState st
@Override @Override
@Deprecated @Deprecated
@SuppressWarnings( "deprecation" )
public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block neighbourBlock, BlockPos neighbourPos ) public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block neighbourBlock, BlockPos neighbourPos )
{ {
TileEntity tile = world.getTileEntity( pos ); TileEntity tile = world.getTileEntity( pos );

View File

@ -63,7 +63,6 @@ public void onNeighbourChange()
{ {
} }
@SuppressWarnings( "deprecation" )
public void onNeighbourChange( @Nonnull BlockPos neighbour ) public void onNeighbourChange( @Nonnull BlockPos neighbour )
{ {
onNeighbourChange(); onNeighbourChange();

View File

@ -220,6 +220,13 @@ public int getInstanceID()
return m_instanceID; return m_instanceID;
} }
/*
* getID and getLabel are deprecated on IComputer, as they do not make sense in ClientComputer.
* However, for compatibility reasons, we still need these here, and have no choice but to override the IComputer methods.
*
* Hence, we suppress the deprecation warning.
*/
@Override @Override
@SuppressWarnings( "deprecation" ) @SuppressWarnings( "deprecation" )
public int getID() public int getID()

View File

@ -90,6 +90,7 @@ public void onRuntimeAvailable( IJeiRuntime runtime )
ingredients.addIngredientsAtRuntime( VanillaTypes.ITEM, upgradeItems ); ingredients.addIngredientsAtRuntime( VanillaTypes.ITEM, upgradeItems );
// Hide all upgrade recipes // Hide all upgrade recipes
@SuppressWarnings( "unchecked" )
IRecipeCategory<? extends IRecipeWrapper> category = (IRecipeCategory<? extends IRecipeWrapper>) registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING ); IRecipeCategory<? extends IRecipeWrapper> category = (IRecipeCategory<? extends IRecipeWrapper>) registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING );
if( category != null ) if( category != null )
{ {

View File

@ -44,7 +44,7 @@ public Vec3d getPosition()
{ {
// FIXME: Should be abstract, but we need this for Plethora compat. We'll // FIXME: Should be abstract, but we need this for Plethora compat. We'll
// be able to change this in a few versions as we implement both there. // be able to change this in a few versions as we implement both there.
@SuppressWarnings( "deprecation" ) BlockPos pos = getPos(); BlockPos pos = getPos();
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
} }

View File

@ -65,7 +65,6 @@ public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
// Remember old block // Remember old block
EnumFacing direction = m_direction.toWorldDir( turtle ); EnumFacing direction = m_direction.toWorldDir( turtle );
World world = turtle.getWorld();
BlockPos coordinates = turtle.getPosition().offset( direction ); BlockPos coordinates = turtle.getPosition().offset( direction );
// Create a fake player, and orient it appropriately // Create a fake player, and orient it appropriately

View File

@ -35,7 +35,6 @@ public static String normaliseLabel( String label )
/** /**
* Translates a Stat name * Translates a Stat name
*/ */
@SuppressWarnings( "deprecation" )
public static String translate( String key ) public static String translate( String key )
{ {
return net.minecraft.util.text.translation.I18n.translateToLocal( key ); return net.minecraft.util.text.translation.I18n.translateToLocal( key );
@ -44,7 +43,6 @@ public static String translate( String key )
/** /**
* Translates a Stat name with format args * Translates a Stat name with format args
*/ */
@SuppressWarnings( "deprecation" )
public static String translateFormatted( String key, Object... format ) public static String translateFormatted( String key, Object... format )
{ {
return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format ); return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format );

View File

@ -25,7 +25,6 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -440,20 +439,6 @@ public Grid( int size )
this.box = (T[]) new Object[size * size * size]; this.box = (T[]) new Object[size * size * size];
} }
public void set( BlockPos pos, T elem )
{
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
if( x >= 0 && x < size && y >= 0 && y < size && z >= 0 && z < size )
{
box[x * size * size + y * size + z] = elem;
}
else
{
throw new IndexOutOfBoundsException( pos.toString() );
}
}
public T get( BlockPos pos ) public T get( BlockPos pos )
{ {
int x = pos.getX(), y = pos.getY(), z = pos.getZ(); int x = pos.getX(), y = pos.getY(), z = pos.getZ();