injector: add interfaces correctly
This commit is contained in:
@@ -36,7 +36,7 @@ buildscript {
|
||||
dependencies {
|
||||
classpath("org.ajoberstar.grgit:grgit-core:4.1.0")
|
||||
classpath("com.github.ben-manes:gradle-versions-plugin:0.36.0")
|
||||
classpath("com.openosrs:openosrs-injector:1.0.1")
|
||||
classpath("com.openosrs:openosrs-injector:1.0.2")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,15 @@ public class Interfaces implements Iterable<Class>
|
||||
classFile = c;
|
||||
}
|
||||
|
||||
public void addInterface(Class clazz)
|
||||
public boolean addInterface(Class clazz)
|
||||
{
|
||||
if (!interfaces.contains(clazz))
|
||||
if (interfaces.stream().noneMatch((itf) -> itf.getName().equals(clazz.getName())))
|
||||
{
|
||||
interfaces.add(clazz);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Class> getInterfaces()
|
||||
|
||||
@@ -15,10 +15,8 @@ plugins {
|
||||
id("se.patrikerdes.use-latest-versions")
|
||||
}
|
||||
|
||||
val oprsver = "3.5.1"
|
||||
|
||||
group = "com.openosrs"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -87,6 +87,7 @@ public class MixinInjector extends AbstractInjector
|
||||
private static final String ASSERTION_FIELD = "$assertionsDisabled";
|
||||
private static final String MIXIN_BASE = "net/runelite/mixins/";
|
||||
|
||||
private int injectedInterfaces = 0;
|
||||
private final Map<String, Field> injectedFields = new HashMap<>();
|
||||
private final Map<net.runelite.asm.pool.Field, ShadowField> shadowFields = new HashMap<>();
|
||||
private int copied = 0, replaced = 0, injected = 0;
|
||||
@@ -106,6 +107,13 @@ public class MixinInjector extends AbstractInjector
|
||||
@VisibleForTesting
|
||||
void inject(Map<Provider<ClassFile>, List<ClassFile>> mixinTargets)
|
||||
{
|
||||
for (Map.Entry<Provider<ClassFile>, List<ClassFile>> entry : mixinTargets.entrySet())
|
||||
{
|
||||
injectInterfaces(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
log.info("[INFO] Injected {} interfaces", injectedInterfaces);
|
||||
|
||||
for (Map.Entry<Provider<ClassFile>, List<ClassFile>> entry : mixinTargets.entrySet())
|
||||
{
|
||||
System.out.println(entry.getKey().get().getName());
|
||||
@@ -157,6 +165,29 @@ public class MixinInjector extends AbstractInjector
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void injectInterfaces(Provider<ClassFile> mixinProvider, List<ClassFile> targetClasses)
|
||||
{
|
||||
try
|
||||
{
|
||||
final ClassFile mixinClass = mixinProvider.get();
|
||||
|
||||
for (final ClassFile targetClass : targetClasses)
|
||||
{
|
||||
mixinClass.getInterfaces().getInterfaces().forEach((itf) ->
|
||||
{
|
||||
if (targetClass.getInterfaces().addInterface(itf))
|
||||
{
|
||||
injectedInterfaces++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void injectFields(Provider<ClassFile> mixinProvider, List<ClassFile> targetClasses)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user