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}")
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;
@Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true)

View File

@@ -27,22 +27,16 @@
package net.runelite.client.rs;
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.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
@@ -59,15 +53,11 @@ import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
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.NONE;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.compress.compressors.CompressorException;
@Slf4j
@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");
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());
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 LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-" + RuneLiteAPI.getVersion() + ".jar");
File INJECTED_CLIENT = new File(RUNELITE_DIR + "/injected-client.jar");
INJECTED_CLIENT.mkdirs();
if (INJECTED_CLIENT.exists()) {
if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url)) {
if (INJECTED_CLIENT.exists())
{
if (getFileSize(INJECTED_CLIENT.toURI().toURL())!= getFileSize(url))
{
INJECTED_CLIENT.delete();
INJECTED_CLIENT.createNewFile();
System.out.println("Updating Injected Client");
updateInjectedClient(readableByteChannel);
}
} else {
}
else
{
INJECTED_CLIENT.createNewFile();
System.out.println("Initializing Inject Client");
updateInjectedClient(readableByteChannel);
}
JarInputStream fis;
if (useLocalInjected) {
if (useLocalInjected)
{
fis = new JarInputStream(new FileInputStream(LOCAL_INJECTED_CLIENT));
} else {
}
else
{
fis = new JarInputStream(new FileInputStream(INJECTED_CLIENT));
}
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;
try {
try
{
conn = url.openConnection();
if(conn instanceof HttpURLConnection) {
((HttpURLConnection)conn).setRequestMethod("HEAD");
if (conn instanceof HttpURLConnection)
{
((HttpURLConnection) conn).setRequestMethod("HEAD");
}
conn.getInputStream();
return conn.getContentLength();
} catch (IOException e) {
}
catch (IOException e)
{
throw new RuntimeException(e);
} finally {
if(conn instanceof HttpURLConnection) {
((HttpURLConnection)conn).disconnect();
}
finally
{
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");
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(INJECTED_CLIENT);
FileChannel fileChannel = fileOutputStream.getChannel();
try
{
FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT);
fileOutputStream.getChannel()
.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
}
catch (IOException e)
{
e.printStackTrace();
}
}