diff --git a/.gitignore b/.gitignore index 0b28ad333..80c50f9b8 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,9 @@ .idea .gradle *.DS_Store + +.classpath +.project +.settings/ +bin/ +*.launch diff --git a/src/main/java/dan200/computercraft/api/filesystem/IMount.java b/src/main/java/dan200/computercraft/api/filesystem/IMount.java index 1fec70994..1952ee9e0 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/IMount.java +++ b/src/main/java/dan200/computercraft/api/filesystem/IMount.java @@ -90,7 +90,6 @@ public interface IMount * @throws IOException If the file does not exist, or could not be opened. */ @Nonnull - @SuppressWarnings( "deprecation" ) default ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOException { return Channels.newChannel( openForRead( path ) ); diff --git a/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java b/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java index e265842e7..38ae27da0 100644 --- a/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java +++ b/src/main/java/dan200/computercraft/api/filesystem/IWritableMount.java @@ -67,7 +67,6 @@ public interface IWritableMount extends IMount * @throws IOException If the file could not be opened for writing. */ @Nonnull - @SuppressWarnings( "deprecation" ) default WritableByteChannel openChannelForWrite( @Nonnull String path ) throws IOException { 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. */ @Nonnull - @SuppressWarnings( "deprecation" ) default WritableByteChannel openChannelForAppend( @Nonnull String path ) throws IOException { return Channels.newChannel( openForAppend( path ) ); diff --git a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java index 23fb93ed3..d1d808f6e 100644 --- a/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/HTTPAPI.java @@ -83,6 +83,7 @@ public String[] getMethodNames() } @Override + @SuppressWarnings( "resource" ) public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull Object[] args ) throws LuaException { switch( method ) @@ -95,7 +96,7 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O if( args.length >= 1 && args[0] instanceof Map ) { - Map options = (Map) args[0]; + Map options = (Map) args[0]; address = getStringField( options, "url" ); postString = optStringField( options, "body", null ); headerTable = optTableField( options, "headers", Collections.emptyMap() ); @@ -135,7 +136,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O try { URI uri = HttpRequest.checkUri( address ); - HttpRequest request = new HttpRequest( requests, m_apiEnvironment, address, postString, headers, binary, redirect ); long requestBody = request.body().readableBytes() + HttpRequest.getHeaderSize( headers ); diff --git a/src/main/java/dan200/computercraft/core/apis/OSAPI.java b/src/main/java/dan200/computercraft/core/apis/OSAPI.java index fbbfe5e0f..d83559207 100644 --- a/src/main/java/dan200/computercraft/core/apis/OSAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/OSAPI.java @@ -401,7 +401,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O Instant instant = Instant.ofEpochSecond( time ); ZonedDateTime date; ZoneOffset offset; - boolean isDst; if( format.startsWith( "!" ) ) { offset = ZoneOffset.UTC; diff --git a/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java b/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java index eb77fe12b..09025978c 100644 --- a/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java +++ b/src/main/java/dan200/computercraft/core/apis/PeripheralAPI.java @@ -356,7 +356,6 @@ public Object[] callMethod( @Nonnull ILuaContext context, int method, @Nonnull O ComputerSide side = ComputerSide.valueOfInsensitive( getString( args, 0 ) ); if( side != null ) { - String type = null; synchronized( m_peripherals ) { PeripheralWrapper p = m_peripherals[side.ordinal()]; diff --git a/src/main/java/dan200/computercraft/core/computer/Computer.java b/src/main/java/dan200/computercraft/core/computer/Computer.java index e1ee67083..101707ca6 100644 --- a/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -239,7 +239,6 @@ public void addAPI( dan200.computercraft.core.apis.ILuaAPI api ) } @Deprecated - @SuppressWarnings( "unused" ) public void advance( double dt ) { tick(); diff --git a/src/main/java/dan200/computercraft/core/filesystem/JarMount.java b/src/main/java/dan200/computercraft/core/filesystem/JarMount.java index 3bedd1eca..24e350330 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/JarMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/JarMount.java @@ -93,7 +93,7 @@ public JarMount( File jarFile, String subPath ) throws IOException new MountReference( this ); // Read in all the entries - root = new FileEntry( "" ); + root = new FileEntry(); Enumeration zipEntries = zip.entries(); while( zipEntries.hasMoreElements() ) { @@ -140,7 +140,7 @@ private void create( ZipEntry entry, String localPath ) FileEntry nextEntry = lastEntry.children.get( part ); if( nextEntry == null || !nextEntry.isDirectory() ) { - lastEntry.children.put( part, nextEntry = new FileEntry( part ) ); + lastEntry.children.put( part, nextEntry = new FileEntry() ); } lastEntry = nextEntry; @@ -224,17 +224,10 @@ public ReadableByteChannel openChannelForRead( @Nonnull String path ) throws IOE private static class FileEntry { - final String name; - String path; long size; Map children; - FileEntry( String name ) - { - this.name = name; - } - void setup( ZipEntry entry ) { path = entry.getName(); diff --git a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java index bc60d2f0e..fa039875e 100644 --- a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java +++ b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java @@ -51,7 +51,6 @@ public final boolean onBlockActivated( World world, BlockPos pos, IBlockState st @Override @Deprecated - @SuppressWarnings( "deprecation" ) public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block neighbourBlock, BlockPos neighbourPos ) { TileEntity tile = world.getTileEntity( pos ); diff --git a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java index 850bf844c..0634f0497 100644 --- a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java +++ b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java @@ -63,7 +63,6 @@ public void onNeighbourChange() { } - @SuppressWarnings( "deprecation" ) public void onNeighbourChange( @Nonnull BlockPos neighbour ) { onNeighbourChange(); diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index f5799af28..e75b55fa3 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -220,6 +220,13 @@ public int getInstanceID() 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 @SuppressWarnings( "deprecation" ) public int getID() diff --git a/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java b/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java index 6ec7aaddf..867b89947 100644 --- a/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java +++ b/src/main/java/dan200/computercraft/shared/integration/jei/JEIComputerCraft.java @@ -90,6 +90,7 @@ public void onRuntimeAvailable( IJeiRuntime runtime ) ingredients.addIngredientsAtRuntime( VanillaTypes.ITEM, upgradeItems ); // Hide all upgrade recipes + @SuppressWarnings( "unchecked" ) IRecipeCategory category = (IRecipeCategory) registry.getRecipeCategory( VanillaRecipeCategoryUid.CRAFTING ); if( category != null ) { diff --git a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java index dcc19ccd9..bda1fe4e0 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java @@ -44,7 +44,7 @@ public Vec3d getPosition() { // 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. - @SuppressWarnings( "deprecation" ) BlockPos pos = getPos(); + BlockPos pos = getPos(); return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ); } diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java index 16fd6e508..34ad51413 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtlePlaceCommand.java @@ -65,7 +65,6 @@ public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle ) // Remember old block EnumFacing direction = m_direction.toWorldDir( turtle ); - World world = turtle.getWorld(); BlockPos coordinates = turtle.getPosition().offset( direction ); // Create a fake player, and orient it appropriately diff --git a/src/main/java/dan200/computercraft/shared/util/StringUtil.java b/src/main/java/dan200/computercraft/shared/util/StringUtil.java index 8c92a25a4..d08f0f8ba 100644 --- a/src/main/java/dan200/computercraft/shared/util/StringUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/StringUtil.java @@ -35,7 +35,6 @@ public static String normaliseLabel( String label ) /** * Translates a Stat name */ - @SuppressWarnings( "deprecation" ) public static String translate( String 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 */ - @SuppressWarnings( "deprecation" ) public static String translateFormatted( String key, Object... format ) { return net.minecraft.util.text.translation.I18n.translateToLocalFormatted( key, format ); diff --git a/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java b/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java index 6a44ccba4..24f121a2a 100644 --- a/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java +++ b/src/test/java/dan200/computercraft/shared/wired/NetworkTest.java @@ -25,7 +25,6 @@ import org.apache.logging.log4j.LogManager; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import javax.annotation.Nonnull; @@ -440,20 +439,6 @@ public Grid( int 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 ) { int x = pos.getX(), y = pos.getY(), z = pos.getZ();