Update clientloader (and tell only developers to turn on assertions)
Make both `--localinjected` and `--rs=CUSTOM` work Make `--rs=VANILLA` work again
This commit is contained in:
@@ -243,7 +243,7 @@ public class RuneLite
|
|||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean developerMode = true;
|
final boolean developerMode = options.has("developer-mode");
|
||||||
|
|
||||||
if (developerMode)
|
if (developerMode)
|
||||||
{
|
{
|
||||||
@@ -290,7 +290,7 @@ public class RuneLite
|
|||||||
|
|
||||||
injector = Guice.createInjector(new RuneLiteModule(
|
injector = Guice.createInjector(new RuneLiteModule(
|
||||||
options.valueOf(updateMode),
|
options.valueOf(updateMode),
|
||||||
developerMode));
|
true));
|
||||||
|
|
||||||
injector.getInstance(RuneLite.class).start();
|
injector.getInstance(RuneLite.class).start();
|
||||||
splashScreen.setProgress(1, 5);
|
splashScreen.setProgress(1, 5);
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ 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.VANILLA;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@@ -63,7 +65,8 @@ import okhttp3.Response;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class ClientLoader
|
public class ClientLoader
|
||||||
{
|
{
|
||||||
private static final File CUSTOMFILE = new File("./injected-client/target/injected-client-1.0-SNAPSHOT.jar");
|
private static final File LOCAL_INJECTED_CLIENT = new File("./injected-client/target/injected-client-" + RuneLiteAPI.getVersion() + ".jar");
|
||||||
|
private static final File INJECTED_CLIENT = new File(RUNELITE_DIR + "/injected-client.jar");
|
||||||
private final ClientConfigLoader clientConfigLoader;
|
private final ClientConfigLoader clientConfigLoader;
|
||||||
private ClientUpdateCheckMode updateCheckMode;
|
private ClientUpdateCheckMode updateCheckMode;
|
||||||
public static boolean useLocalInjected = false;
|
public static boolean useLocalInjected = false;
|
||||||
@@ -86,6 +89,8 @@ public class ClientLoader
|
|||||||
RSConfig config = clientConfigLoader.fetch();
|
RSConfig config = clientConfigLoader.fetch();
|
||||||
|
|
||||||
Map<String, byte[]> zipFile = new HashMap<>();
|
Map<String, byte[]> zipFile = new HashMap<>();
|
||||||
|
|
||||||
|
if (updateCheckMode == VANILLA)
|
||||||
{
|
{
|
||||||
Certificate[] jagexCertificateChain = getJagexCertificateChain();
|
Certificate[] jagexCertificateChain = getJagexCertificateChain();
|
||||||
String codebase = config.getCodeBase();
|
String codebase = config.getCodeBase();
|
||||||
@@ -139,63 +144,27 @@ public class ClientLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
URL url = new URL("https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/injected-client.jar");
|
else if (updateCheckMode == CUSTOM || useLocalInjected)
|
||||||
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");
|
|
||||||
INJECTED_CLIENT.mkdirs();
|
|
||||||
if (INJECTED_CLIENT.exists())
|
|
||||||
{
|
{
|
||||||
if (getFileSize(INJECTED_CLIENT.toURI().toURL()) != getFileSize(url))
|
log.info("Loading injected client from {}", LOCAL_INJECTED_CLIENT.getAbsolutePath());
|
||||||
|
loadJar(zipFile, LOCAL_INJECTED_CLIENT);
|
||||||
|
}
|
||||||
|
else if (updateCheckMode == AUTO)
|
||||||
|
{
|
||||||
|
URL url = new URL("https://raw.githubusercontent.com/runelite-extended/maven-repo/master/live/injected-client.jar");
|
||||||
|
ReadableByteChannel readableByteChannel = Channels.newChannel(url.openStream());
|
||||||
|
INJECTED_CLIENT.mkdirs();
|
||||||
|
|
||||||
|
if (!INJECTED_CLIENT.exists() || getFileSize(INJECTED_CLIENT.toURI().toURL()) != getFileSize(url))
|
||||||
{
|
{
|
||||||
|
log.info("{} injected client", INJECTED_CLIENT.exists() ? "Updating" : "Initializing");
|
||||||
INJECTED_CLIENT.delete();
|
INJECTED_CLIENT.delete();
|
||||||
INJECTED_CLIENT.createNewFile();
|
INJECTED_CLIENT.createNewFile();
|
||||||
System.out.println("Updating Injected Client");
|
|
||||||
updateInjectedClient(readableByteChannel);
|
updateInjectedClient(readableByteChannel);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
INJECTED_CLIENT.createNewFile();
|
|
||||||
System.out.println("Initializing Inject Client");
|
|
||||||
updateInjectedClient(readableByteChannel);
|
|
||||||
}
|
|
||||||
|
|
||||||
JarInputStream fis;
|
log.info("Loading injected client from {}", INJECTED_CLIENT.getAbsolutePath());
|
||||||
|
loadJar(zipFile, INJECTED_CLIENT);
|
||||||
if (updateCheckMode == CUSTOM)
|
|
||||||
{
|
|
||||||
System.out.println("Using local injected client");
|
|
||||||
fis = new JarInputStream(new FileInputStream(LOCAL_INJECTED_CLIENT));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("Using live injected client");
|
|
||||||
fis = new JarInputStream(new FileInputStream(INJECTED_CLIENT));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
byte[] tmp = new byte[4096];
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
JarEntry metadata = fis.getNextJarEntry();
|
|
||||||
if (metadata == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.reset();
|
|
||||||
for (; ; )
|
|
||||||
{
|
|
||||||
int n = fis.read(tmp);
|
|
||||||
if (n <= -1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buffer.write(tmp, 0, n);
|
|
||||||
}
|
|
||||||
zipFile.replace(metadata.getName(), buffer.toByteArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String initialClass = config.getInitialClass();
|
String initialClass = config.getInitialClass();
|
||||||
@@ -242,7 +211,7 @@ public class ClientLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getFileSize(URL url)
|
private static int getFileSize(URL url) throws IOException
|
||||||
{
|
{
|
||||||
URLConnection conn = null;
|
URLConnection conn = null;
|
||||||
try
|
try
|
||||||
@@ -255,10 +224,6 @@ public class ClientLoader
|
|||||||
conn.getInputStream();
|
conn.getInputStream();
|
||||||
return conn.getContentLength();
|
return conn.getContentLength();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (conn instanceof HttpURLConnection)
|
if (conn instanceof HttpURLConnection)
|
||||||
@@ -268,19 +233,11 @@ public class ClientLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInjectedClient(ReadableByteChannel readableByteChannel)
|
private void updateInjectedClient(ReadableByteChannel readableByteChannel) throws IOException
|
||||||
{
|
{
|
||||||
File INJECTED_CLIENT = new File(RUNELITE_DIR, "injected-client.jar");
|
FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT);
|
||||||
try
|
fileOutputStream.getChannel()
|
||||||
{
|
.transferFrom(readableByteChannel, 0, Integer.MAX_VALUE);
|
||||||
FileOutputStream fileOutputStream = new FileOutputStream(INJECTED_CLIENT);
|
|
||||||
fileOutputStream.getChannel()
|
|
||||||
.transferFrom(readableByteChannel, 0, Integer.MAX_VALUE);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Certificate[] getJagexCertificateChain() throws CertificateException
|
private static Certificate[] getJagexCertificateChain() throws CertificateException
|
||||||
@@ -289,4 +246,31 @@ public class ClientLoader
|
|||||||
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
||||||
return certificates.toArray(new Certificate[0]);
|
return certificates.toArray(new Certificate[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void loadJar(Map<String, byte[]> toMap, File fromFile) throws IOException
|
||||||
|
{
|
||||||
|
JarInputStream fis = new JarInputStream(new FileInputStream(fromFile));
|
||||||
|
byte[] tmp = new byte[4096];
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
JarEntry metadata = fis.getNextJarEntry();
|
||||||
|
if (metadata == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.reset();
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
int n = fis.read(tmp);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer.write(tmp, 0, n);
|
||||||
|
}
|
||||||
|
toMap.put(metadata.getName(), buffer.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user