make the injector more reliable
This commit is contained in:
@@ -126,7 +126,7 @@ tasks {
|
||||
}
|
||||
|
||||
compileJava {
|
||||
dependsOn("packInjectedClient")
|
||||
// dependsOn("packInjectedClient")
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -155,9 +155,11 @@ tasks {
|
||||
register<Copy>("packInjectedClient") {
|
||||
dependsOn(":injector:inject")
|
||||
|
||||
from("src/main/resources/")
|
||||
from("build/injected/")
|
||||
include("**/injected-client.oprs")
|
||||
into("${buildDir}/resources/main")
|
||||
|
||||
outputs.upToDateWhen { false }
|
||||
}
|
||||
|
||||
jar {
|
||||
@@ -174,6 +176,10 @@ tasks {
|
||||
dependsOn(":runelite-script-assembler-plugin:assembleMojo")
|
||||
|
||||
from("${buildDir}/scripts")
|
||||
|
||||
dependsOn(":injector:inject")
|
||||
|
||||
from("build/injected")
|
||||
}
|
||||
|
||||
withType<BootstrapTask> {
|
||||
|
||||
@@ -72,6 +72,7 @@ import org.apache.commons.io.FileUtils;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ClientLoader implements Supplier<Applet>
|
||||
{
|
||||
private static final String INJECTED_CLIENT_NAME = "/injected-client.oprs";
|
||||
private static final int NUM_ATTEMPTS = 6;
|
||||
private static File LOCK_FILE = new File(RuneLite.CACHE_DIR, "cache.lock");
|
||||
private static File VANILLA_CACHE = new File(RuneLite.CACHE_DIR, "vanilla.cache");
|
||||
@@ -132,9 +133,11 @@ public class ClientLoader implements Supplier<Applet>
|
||||
// create the classloader for the jar while we hold the lock, and eagerly load and link all classes
|
||||
// in the jar. Otherwise the jar can change on disk and can break future classloads.
|
||||
File oprsInjected = new File(System.getProperty("user.home") + "/.openosrs/cache/injected-client.jar");
|
||||
InputStream initialStream = RuneLite.class.getResourceAsStream("injected-client.oprs");
|
||||
if (!oprsInjected.exists() || oprsInjected.length() != RuneLite.class.getResource("injected-client.oprs").getFile().length())
|
||||
InputStream initialStream = RuneLite.class.getResourceAsStream(INJECTED_CLIENT_NAME);
|
||||
if (!oprsInjected.exists() || oprsInjected.length() != RuneLite.class.getResource(INJECTED_CLIENT_NAME).getFile().length())
|
||||
{
|
||||
FileUtils.copyInputStreamToFile(initialStream, oprsInjected);
|
||||
}
|
||||
|
||||
classLoader = createJarClassLoader(oprsInjected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user