allow specifying remapping steps
All checks were successful
Publish to snapshot maven / build (push) Successful in 19s
All checks were successful
Publish to snapshot maven / build (push) Successful in 19s
This commit is contained in:
parent
068928ad3d
commit
25fefae245
|
@ -8,7 +8,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.frogmc"
|
group = "dev.frogmc"
|
||||||
version = "0.0.1-alpha.6"
|
version = "0.0.1-alpha.7"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
8
src/main/java/dev/frogmc/thyroxine/RemappingStep.java
Normal file
8
src/main/java/dev/frogmc/thyroxine/RemappingStep.java
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package dev.frogmc.thyroxine;
|
||||||
|
|
||||||
|
import org.objectweb.asm.ClassVisitor;
|
||||||
|
import org.objectweb.asm.commons.Remapper;
|
||||||
|
|
||||||
|
public interface RemappingStep {
|
||||||
|
ClassVisitor run(ClassVisitor previous, Remapper remapper);
|
||||||
|
}
|
|
@ -3,18 +3,21 @@ package dev.frogmc.thyroxine;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
|
import dev.frogmc.thyroxine.api.Mapper;
|
||||||
import dev.frogmc.thyroxine.api.ParameterClassRemapper;
|
import dev.frogmc.thyroxine.api.ParameterClassRemapper;
|
||||||
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
import dev.frogmc.thyroxine.api.data.MappingBundle;
|
||||||
|
import dev.frogmc.thyroxine.api.data.MappingData;
|
||||||
import dev.frogmc.thyroxine.provider.MojmapProvider;
|
import dev.frogmc.thyroxine.provider.MojmapProvider;
|
||||||
import dev.frogmc.thyroxine.provider.ParchmentProvider;
|
import dev.frogmc.thyroxine.provider.ParchmentProvider;
|
||||||
import dev.frogmc.thyroxine.api.Mapper;
|
|
||||||
import dev.frogmc.thyroxine.api.data.MappingData;
|
|
||||||
import org.objectweb.asm.ClassReader;
|
import org.objectweb.asm.ClassReader;
|
||||||
import org.objectweb.asm.ClassVisitor;
|
import org.objectweb.asm.ClassVisitor;
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
@ -51,6 +54,14 @@ public class Thyroxine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remap(MappingData data, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
public static void remap(MappingData data, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
|
||||||
|
List<RemappingStep> steps = List.of(
|
||||||
|
ClassRemapper::new,
|
||||||
|
(cv, mapper) -> renameParameters ? new ParameterClassRemapper(cv, mapper, data) : cv
|
||||||
|
);
|
||||||
|
remap(data, inputJar, outputJar, skipMetaInf, steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remap(MappingData data, Path inputJar, Path outputJar, boolean skipMetaInf, List<RemappingStep> steps) throws IOException, InterruptedException {
|
||||||
Files.deleteIfExists(outputJar);
|
Files.deleteIfExists(outputJar);
|
||||||
|
|
||||||
System.out.println("Remapping...");
|
System.out.println("Remapping...");
|
||||||
|
@ -88,12 +99,9 @@ public class Thyroxine {
|
||||||
byte[] bytes = Files.readAllBytes(path);
|
byte[] bytes = Files.readAllBytes(path);
|
||||||
ClassReader reader = new ClassReader(bytes);
|
ClassReader reader = new ClassReader(bytes);
|
||||||
ClassWriter writer = new ClassWriter(0);
|
ClassWriter writer = new ClassWriter(0);
|
||||||
ClassVisitor remapper = new ClassRemapper(writer, mapper);
|
ClassVisitor visitor = writer;
|
||||||
ClassVisitor visitor;
|
for (RemappingStep pass : steps) {
|
||||||
if (renameParameters) {
|
visitor = pass.run(visitor, mapper);
|
||||||
visitor = new ParameterClassRemapper(remapper, mapper, data);
|
|
||||||
} else {
|
|
||||||
visitor = remapper;
|
|
||||||
}
|
}
|
||||||
reader.accept(visitor, 0);
|
reader.accept(visitor, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue