Skip to content

Commit

Permalink
fix: Optimize transformer so we only transform events
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofbolyai committed Nov 25, 2022
1 parent 9e09e9a commit 21e3042
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group "com.wynntils.eventbustransformer"
version = "1.1.0"
version = "1.1.1"

java {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public dev.architectury.transformer.shadowed.impl.org.objectweb.asm.tree.ClassNo
}

Type type = Type.getObjectType(node.name);
if (engine.handlesClass(type) && type.getClassName().startsWith("com.wynntils")) {
LOGGER.info("Transforming class " + type.getClassName());
String className = type.getClassName();
if (engine.handlesClass(type) && className.startsWith("com.wynntils") && className.contains("Event")) {
LOGGER.info("Transforming class " + className);
dev.architectury.transformer.shadowed.impl.org.objectweb.asm.ClassWriter architecturyClassWriter = new dev.architectury.transformer.shadowed.impl.org.objectweb.asm.ClassWriter(0);
node.accept(architecturyClassWriter);
ClassReader normalClassReader = new ClassReader(architecturyClassWriter.toByteArray());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/wynntils/eventbustransformer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public static void main(String[] args) throws IOException {
byte[] content = IOUtils.toByteArray(zip.getInputStream(next));
if (next.getName().endsWith(".class")) {
Type type = Type.getObjectType(next.getName().replace(".class", ""));
if (engine.handlesClass(type) && type.getClassName().startsWith("com.wynntils")) {
String className = type.getClassName();
if (engine.handlesClass(type) && className.startsWith("com.wynntils") && className.contains("Event")) {
LOGGER.info("Transforming class " + type.getClassName());
ClassReader reader = new ClassReader(content);
ClassNode node = new ClassNode();
Expand Down

0 comments on commit 21e3042

Please sign in to comment.