project: Fix deprecations and supress unchecked warnings

This commit is contained in:
Owain van Brakel
2019-07-25 20:08:45 +02:00
parent 481831359b
commit 17b35205fd
40 changed files with 113 additions and 263 deletions

View File

@@ -56,7 +56,7 @@ public class ScriptLoader
int numSwitches = in.readUnsignedByte();
if (numSwitches > 0)
{
Map<Integer, Integer>[] switches = new Map[numSwitches];
@SuppressWarnings("unchecked") Map<Integer, Integer>[] switches = new Map[numSwitches];
def.setSwitches(switches);
for (int i = 0; i < numSwitches; ++i)

View File

@@ -36,6 +36,7 @@ import net.runelite.cache.region.Position;
public class WorldMapLoader
{
@SuppressWarnings("unchecked")
public WorldMapDefinition load(byte[] b, int fileId)
{
WorldMapDefinition def = new WorldMapDefinition();

View File

@@ -29,7 +29,7 @@ import java.io.InputStream;
import net.runelite.cache.definitions.ScriptDefinition;
import net.runelite.cache.script.Instructions;
import net.runelite.cache.script.assembler.rs2asmParser.ProgContext;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
@@ -45,7 +45,7 @@ public class Assembler
public ScriptDefinition assemble(InputStream in) throws IOException
{
// Get our lexer
rs2asmLexer lexer = new rs2asmLexer(new ANTLRInputStream(in));
rs2asmLexer lexer = new rs2asmLexer(CharStreams.fromStream(in));
LexerErrorListener errorListener = new LexerErrorListener();
lexer.addErrorListener(errorListener);

View File

@@ -259,7 +259,7 @@ public class ScriptWriter extends rs2asmBaseListener
}
int index = 0;
Map<Integer, Integer>[] maps = new Map[count];
@SuppressWarnings("unchecked") Map<Integer, Integer>[] maps = new Map[count];
for (LookupSwitch lswitch : switches)
{
if (lswitch == null)

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.cache;
import com.google.common.io.FileWriteMode;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -81,7 +82,7 @@ public class SoundEffectsDumperTest
SoundEffectTrackLoader setLoader = new SoundEffectTrackLoader();
SoundEffectTrackDefinition soundEffect = setLoader.load(contents);
Files.write(gson.toJson(soundEffect), new File(dumpDir, archive.getArchiveId() + ".json"), Charset.defaultCharset());
Files.asCharSink(new File(dumpDir, archive.getArchiveId() + ".json"), Charset.defaultCharset()).write(gson.toJson(soundEffect));
++count;
}
}