injector: move initialization to main
This commit is contained in:
@@ -115,7 +115,7 @@ public class JarUtil
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveJar(ClassGroup group, File jarfile) throws IOException
|
public static void saveJar(ClassGroup group, File jarfile)
|
||||||
{
|
{
|
||||||
try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile)))
|
try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile)))
|
||||||
{
|
{
|
||||||
@@ -131,6 +131,10 @@ public class JarUtil
|
|||||||
jout.closeEntry();
|
jout.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeClass(ClassGroup group, ClassFile cf)
|
public static byte[] writeClass(ClassGroup group, ClassFile cf)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.openosrs.injector.rsapi.RSApi;
|
|||||||
import com.openosrs.injector.transformers.InjectTransformer;
|
import com.openosrs.injector.transformers.InjectTransformer;
|
||||||
import com.openosrs.injector.transformers.SourceChanger;
|
import com.openosrs.injector.transformers.SourceChanger;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.util.Objects;
|
||||||
import net.runelite.deob.util.JarUtil;
|
import net.runelite.deob.util.JarUtil;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
@@ -34,30 +34,28 @@ public class Injector extends InjectData implements InjectTaskHandler
|
|||||||
{
|
{
|
||||||
private static final Logger log = Logging.getLogger(Injector.class);
|
private static final Logger log = Logging.getLogger(Injector.class);
|
||||||
|
|
||||||
public Injector(File vanilla, File rsclient, File mixins, File[] rsapi) throws IOException
|
private static Injector injector;
|
||||||
{
|
static File injectedClientOutput = new File("../runelite-client/src/main/resources/net/runelite/client/injected-client.oprs");
|
||||||
super(
|
|
||||||
JarUtil.loadJar(vanilla),
|
|
||||||
JarUtil.loadJar(rsclient),
|
|
||||||
JarUtil.loadJar(mixins),
|
|
||||||
new RSApi(rsapi)
|
|
||||||
);
|
|
||||||
inject();
|
|
||||||
save(new File("../runelite-client/src/main/resources/net/runelite/client/injected-client.oprs"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
args = new String[]
|
File vanilla = new File(args[0]);
|
||||||
{
|
File rsClient = new File("../runescape-client/build/libs/runescape-client-" + args[1] + ".jar");
|
||||||
args[0],
|
File mixins = new File("../runelite-mixins/build/libs/runelite-mixins-" + args[1] + ".jar");
|
||||||
"../runescape-client/build/libs/runescape-client-" + args[1] + ".jar",
|
RSApi rsApi = new RSApi(Objects.requireNonNull(
|
||||||
"../runelite-mixins/build/libs/runelite-mixins-" + args[1] + ".jar",
|
new File("../runescape-api/build/classes/java/main/net/runelite/rs/api/")
|
||||||
"../runescape-api/build/classes/java/main/net/runelite/rs/api/"
|
.listFiles()));
|
||||||
};
|
|
||||||
new Injector(new File(args[0]), new File(args[1]), new File(args[2]), new File(args[3]).listFiles());
|
injector = new Injector();
|
||||||
|
injector.vanilla = JarUtil.loadJar(vanilla);
|
||||||
|
injector.deobfuscated = JarUtil.loadJar(rsClient);
|
||||||
|
injector.rsApi = rsApi;
|
||||||
|
injector.mixins = JarUtil.loadJar(mixins);
|
||||||
|
injector.initToVanilla();
|
||||||
|
injector.inject();
|
||||||
|
save(injectedClientOutput);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -106,11 +104,11 @@ public class Injector extends InjectData implements InjectTaskHandler
|
|||||||
transform(new SourceChanger(this));
|
transform(new SourceChanger(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(File outputJar) throws IOException
|
public static void save(File outputJar)
|
||||||
{
|
{
|
||||||
log.info("[INFO] Saving jar to {}", outputJar.toString());
|
log.info("[INFO] Saving jar to {}", outputJar.toString());
|
||||||
|
|
||||||
JarUtil.saveJar(this.getVanilla(), outputJar);
|
JarUtil.saveJar(injector.getVanilla(), outputJar);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inject(com.openosrs.injector.injectors.Injector injector)
|
private void inject(com.openosrs.injector.injectors.Injector injector)
|
||||||
|
|||||||
@@ -31,21 +31,21 @@ public abstract class InjectData
|
|||||||
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
|
public static final String CALLBACKS = "net/runelite/api/hooks/Callbacks";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final ClassGroup vanilla;
|
public ClassGroup vanilla;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final ClassGroup deobfuscated;
|
public ClassGroup deobfuscated;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final ClassGroup mixins;
|
public ClassGroup mixins;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final RSApi rsApi;
|
public RSApi rsApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deobfuscated ClassFiles -> Vanilla ClassFiles
|
* Deobfuscated ClassFiles -> Vanilla ClassFiles
|
||||||
*/
|
*/
|
||||||
private final Map<ClassFile, ClassFile> toVanilla;
|
public Map<ClassFile, ClassFile> toVanilla;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strings -> Deobfuscated ClassFiles
|
* Strings -> Deobfuscated ClassFiles
|
||||||
@@ -55,18 +55,9 @@ public abstract class InjectData
|
|||||||
*/
|
*/
|
||||||
private final Map<String, ClassFile> toDeob = new HashMap<>();
|
private final Map<String, ClassFile> toDeob = new HashMap<>();
|
||||||
|
|
||||||
public InjectData(ClassGroup vanilla, ClassGroup deobfuscated, ClassGroup mixins, RSApi rsApi)
|
|
||||||
{
|
|
||||||
this.vanilla = vanilla;
|
|
||||||
this.deobfuscated = deobfuscated;
|
|
||||||
this.rsApi = rsApi;
|
|
||||||
this.mixins = mixins;
|
|
||||||
this.toVanilla = initToVanilla();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void runChildInjector(Injector injector);
|
public abstract void runChildInjector(Injector injector);
|
||||||
|
|
||||||
private Map<ClassFile, ClassFile> initToVanilla()
|
public void initToVanilla()
|
||||||
{
|
{
|
||||||
ImmutableMap.Builder<ClassFile, ClassFile> toVanillaB = ImmutableMap.builder();
|
ImmutableMap.Builder<ClassFile, ClassFile> toVanillaB = ImmutableMap.builder();
|
||||||
|
|
||||||
@@ -88,7 +79,7 @@ public abstract class InjectData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return toVanillaB.build();
|
this.toVanilla = toVanillaB.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,9 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.openosrs.injector.injection;
|
package com.openosrs.injector.injection;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface containing all the methods gradle needs to know about
|
* Interface containing all the methods gradle needs to know about
|
||||||
*/
|
*/
|
||||||
@@ -19,9 +16,4 @@ public interface InjectTaskHandler
|
|||||||
* The actual method that does all the work
|
* The actual method that does all the work
|
||||||
*/
|
*/
|
||||||
void inject();
|
void inject();
|
||||||
|
|
||||||
/**
|
|
||||||
* Call this to save the injected jar to outputJar
|
|
||||||
*/
|
|
||||||
void save(File outputJar) throws IOException;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user