Checkstyle + overseen mistakes

This commit is contained in:
Lucas
2019-06-08 23:37:10 +02:00
parent d0d0d14a2f
commit 3bbbda23ed
2 changed files with 39 additions and 34 deletions

View File

@@ -48,7 +48,7 @@ public class InjectMojo extends AbstractMojo
@Parameter(defaultValue = "${project.build.outputDirectory}") @Parameter(defaultValue = "${project.build.outputDirectory}")
private File outputDirectory; private File outputDirectory;
@Parameter(defaultValue = "./rs-client/target/rs-client-${project.version}.jar", readonly = true, required = true) @Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true)
private String rsClientPath; private String rsClientPath;
@Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true) @Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true)

View File

@@ -27,22 +27,16 @@
package net.runelite.client.rs; package net.runelite.client.rs;
import net.runelite.api.Client; import net.runelite.api.Client;
import com.google.common.io.ByteStreams;
import io.sigpipe.jbsdiff.InvalidHeaderException;
import io.sigpipe.jbsdiff.Patch;
import java.applet.Applet; import java.applet.Applet;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.security.cert.Certificate; import java.security.cert.Certificate;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
@@ -59,15 +53,11 @@ import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import static net.runelite.client.RuneLite.RUNELITE_DIR; import static net.runelite.client.RuneLite.RUNELITE_DIR;
import static net.runelite.client.rs.ClientUpdateCheckMode.AUTO;
import static net.runelite.client.rs.ClientUpdateCheckMode.CUSTOM; import static net.runelite.client.rs.ClientUpdateCheckMode.CUSTOM;
import static net.runelite.client.rs.ClientUpdateCheckMode.NONE;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.apache.commons.compress.compressors.CompressorException;
@Slf4j @Slf4j
@Singleton @Singleton
@@ -155,25 +145,32 @@ public class ClientLoader
{ {
URL url = new URL("https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/injected-client.jar"); URL url = new URL("https://raw.githubusercontent.com/runelite-extended/maven-repo/master/artifacts/injected-client.jar");
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream()); ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());
File LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-"+RuneLiteAPI.getVersion()+".jar"); File LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-" + RuneLiteAPI.getVersion() + ".jar");
File INJECTED_CLIENT = new File(RUNELITE_DIR+"/injected-client.jar"); File INJECTED_CLIENT = new File(RUNELITE_DIR + "/injected-client.jar");
INJECTED_CLIENT.mkdirs(); INJECTED_CLIENT.mkdirs();
if (INJECTED_CLIENT.exists()) { if (INJECTED_CLIENT.exists())
if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url)) { {
if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url))
{
INJECTED_CLIENT.delete(); INJECTED_CLIENT.delete();
INJECTED_CLIENT.createNewFile(); INJECTED_CLIENT.createNewFile();
System.out.println("Updating Injected Client"); System.out.println("Updating Injected Client");
updateInjectedClient(readableByteChannel); updateInjectedClient(readableByteChannel);
} }
} else { }
else
{
INJECTED_CLIENT.createNewFile(); INJECTED_CLIENT.createNewFile();
System.out.println("Initializing Inject Client"); System.out.println("Initializing Inject Client");
updateInjectedClient(readableByteChannel); updateInjectedClient(readableByteChannel);
} }
JarInputStream fis; JarInputStream fis;
if (useLocalInjected) { if (useLocalInjected)
{
fis = new JarInputStream(new FileInputStream(LOCAL_INJECTED_CLIENT)); fis = new JarInputStream(new FileInputStream(LOCAL_INJECTED_CLIENT));
} else { }
else
{
fis = new JarInputStream(new FileInputStream(INJECTED_CLIENT)); fis = new JarInputStream(new FileInputStream(INJECTED_CLIENT));
} }
byte[] tmp = new byte[4096]; byte[] tmp = new byte[4096];
@@ -244,35 +241,43 @@ public class ClientLoader
} }
} }
private static int getFileSize(URL url) { private static int getFileSize(URL url)
{
URLConnection conn = null; URLConnection conn = null;
try { try
{
conn = url.openConnection(); conn = url.openConnection();
if(conn instanceof HttpURLConnection) { if (conn instanceof HttpURLConnection)
((HttpURLConnection)conn).setRequestMethod("HEAD"); {
((HttpURLConnection) conn).setRequestMethod("HEAD");
} }
conn.getInputStream(); conn.getInputStream();
return conn.getContentLength(); return conn.getContentLength();
} catch (IOException e) { }
catch (IOException e)
{
throw new RuntimeException(e); throw new RuntimeException(e);
} finally { }
if(conn instanceof HttpURLConnection) { finally
((HttpURLConnection)conn).disconnect(); {
if (conn instanceof HttpURLConnection)
{
((HttpURLConnection) conn).disconnect();
} }
} }
} }
private void updateInjectedClient(ReadableByteChannel readableByteChannel) { private void updateInjectedClient(ReadableByteChannel readableByteChannel)
{
File INJECTED_CLIENT = new File(RUNELITE_DIR,"injected-client.jar"); File INJECTED_CLIENT = new File(RUNELITE_DIR,"injected-client.jar");
FileOutputStream fileOutputStream = null; try
try { {
fileOutputStream = new FileOutputStream(INJECTED_CLIENT); FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT);
FileChannel fileChannel = fileOutputStream.getChannel();
fileOutputStream.getChannel() fileOutputStream.getChannel()
.transferFrom(readableByteChannel, 0, Long.MAX_VALUE); .transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (FileNotFoundException e) { }
e.printStackTrace(); catch (IOException e)
} catch (IOException e) { {
e.printStackTrace(); e.printStackTrace();
} }
} }