allow renaming parameters even without parchment
All checks were successful
Publish to snapshot maven / build (push) Successful in 20s

This commit is contained in:
moehreag 2024-06-16 14:07:13 +02:00
parent ba6c5ea32c
commit 5eaeaba14f
3 changed files with 7 additions and 13 deletions

View file

@ -8,7 +8,7 @@ plugins {
}
group = "dev.frogmc"
version = "0.0.1-alpha.2"
version = "0.0.1-alpha.3"
repositories {
mavenCentral()
@ -29,7 +29,8 @@ tasks.jar {
manifest {
attributes("Implementation-Version" to version,
"Implementation-Name" to project.name,
"Implementation-Date" to Date())
"Implementation-Date" to Date(),
"Main-Class" to "dev.frogmc.thyroxine.Thyroxine")
}
}

View file

@ -75,14 +75,7 @@ public class Thyroxine {
ClassReader reader = new ClassReader(bytes);
ClassWriter writer = new ClassWriter(0);
ClassVisitor remapper = new ClassRemapper(writer, mapper);
ClassVisitor visitor;
if (paramMappings != null) {
visitor = new ParameterClassRemapper(remapper, mapper, paramMappings);
} else {
visitor = remapper;
}
reader.accept(visitor, 0);
reader.accept(new ParameterClassRemapper(remapper, mapper, paramMappings), 0);
byte[] output = writer.toByteArray();
Files.createDirectories(result.getParent());
@ -106,7 +99,7 @@ public class Thyroxine {
exec.invokeAll(tasks);
System.out.printf("Finished remapping (%.2fs)\n", (System.currentTimeMillis() - startTime) / 1000F);
System.out.printf("Finished remapping (%.2fs)%n", (System.currentTimeMillis() - startTime) / 1000F);
}
}

View file

@ -21,8 +21,8 @@ public class ParameterClassRemapper extends ClassRemapper {
MethodVisitor methodVisitor = cv.visitMethod(access, remapper.mapMethodName(className, name, descriptor), remappedDescriptor,
remapper.mapSignature(signature, false), exceptions == null ? null : remapper.mapTypes(exceptions));
Parchment.Method method = parchment.getClass(remapper.map(className)).flatMap(c -> c.getMethod(remapper.mapMethodName(className, name, descriptor), remapper.mapMethodDesc(descriptor)))
.orElse(null);
Parchment.Method method = parchment != null ? parchment.getClass(remapper.map(className)).flatMap(c -> c.getMethod(remapper.mapMethodName(className, name, descriptor), remapper.mapMethodDesc(descriptor)))
.orElse(null) : null;
return methodVisitor == null ? null : new ParameterMethodRemapper(methodVisitor, remapper, method);
}