make the injector more reliable

This commit is contained in:
ThatGamerBlue
2021-04-21 00:25:08 +01:00
parent e9f4e3ab58
commit 3e8318e18a
16 changed files with 168 additions and 83 deletions

View File

@@ -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);
}