Add custom client updatecheck mode to easily load from file
This commit is contained in:
@@ -31,6 +31,8 @@ import io.sigpipe.jbsdiff.InvalidHeaderException;
|
|||||||
import io.sigpipe.jbsdiff.Patch;
|
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.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -51,6 +53,7 @@ import javax.inject.Singleton;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import static net.runelite.client.rs.ClientUpdateCheckMode.AUTO;
|
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 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;
|
||||||
@@ -61,6 +64,7 @@ import org.apache.commons.compress.compressors.CompressorException;
|
|||||||
@Singleton
|
@Singleton
|
||||||
public class ClientLoader
|
public class ClientLoader
|
||||||
{
|
{
|
||||||
|
private static final File CUSTOMFILE = new File("replace me!");
|
||||||
private final ClientConfigLoader clientConfigLoader;
|
private final ClientConfigLoader clientConfigLoader;
|
||||||
private ClientUpdateCheckMode updateCheckMode;
|
private ClientUpdateCheckMode updateCheckMode;
|
||||||
|
|
||||||
@@ -170,6 +174,33 @@ public class ClientLoader
|
|||||||
log.info("Patched {} classes", patchCount);
|
log.info("Patched {} classes", patchCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateCheckMode == CUSTOM)
|
||||||
|
{
|
||||||
|
JarInputStream fis = new JarInputStream(new FileInputStream(CUSTOMFILE));
|
||||||
|
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();
|
||||||
|
|
||||||
ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader())
|
ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader())
|
||||||
|
|||||||
@@ -28,5 +28,6 @@ public enum ClientUpdateCheckMode
|
|||||||
{
|
{
|
||||||
AUTO,
|
AUTO,
|
||||||
NONE,
|
NONE,
|
||||||
VANILLA
|
VANILLA,
|
||||||
|
CUSTOM
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user