fix what I broke
This commit is contained in:
parent
ff6ce3210b
commit
47ea5135d3
|
@ -1,5 +1,6 @@
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
java
|
||||||
|
`java-library`
|
||||||
id("io.freefair.lombok").version("8.6+")
|
id("io.freefair.lombok").version("8.6+")
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
@ -23,8 +24,7 @@ dependencies {
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("maven") {
|
create<MavenPublication>("mavenJava") {
|
||||||
|
|
||||||
from(components["java"])
|
from(components["java"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
||||||
#Sat Apr 27 20:33:54 CEST 2024
|
#Sat Apr 27 20:33:54 CEST 2024
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package org.ecorous.esnesnon.mojmap_patcher;
|
package org.ecorous.esnesnon.mojmap_patcher;
|
||||||
|
|
||||||
import org.ecorous.esnesnon.mojmap_patcher.api.Mapper;
|
|
||||||
import org.ecorous.esnesnon.mojmap_patcher.api.data.MappingData;
|
|
||||||
import org.ecorous.esnesnon.mojmap_patcher.provider.MojmapProvider;
|
|
||||||
import org.ecorous.esnesnon.mojmap_patcher.parser.ProguardParser;
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.commons.ClassRemapper;
|
|
||||||
|
|
||||||
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.Map;
|
||||||
|
|
||||||
|
import org.ecorous.esnesnon.mojmap_patcher.api.Mapper;
|
||||||
|
import org.ecorous.esnesnon.mojmap_patcher.api.data.MappingData;
|
||||||
|
import org.ecorous.esnesnon.mojmap_patcher.parser.ProguardParser;
|
||||||
|
import org.ecorous.esnesnon.mojmap_patcher.provider.MojmapProvider;
|
||||||
|
import org.objectweb.asm.ClassReader;
|
||||||
|
import org.objectweb.asm.ClassWriter;
|
||||||
|
import org.objectweb.asm.commons.ClassRemapper;
|
||||||
|
|
||||||
public class MojMapPatcher {
|
public class MojMapPatcher {
|
||||||
|
|
||||||
|
@ -19,26 +20,31 @@ public class MojMapPatcher {
|
||||||
|
|
||||||
Mapper mapper = new Mapper(data);
|
Mapper mapper = new Mapper(data);
|
||||||
|
|
||||||
if (!Files.exists(outputJar)){
|
Files.deleteIfExists(outputJar);
|
||||||
Files.createFile(outputJar);
|
|
||||||
}
|
|
||||||
|
|
||||||
try (FileSystem inFs = FileSystems.newFileSystem(inputJar);
|
try (FileSystem inFs = FileSystems.newFileSystem(inputJar);
|
||||||
FileSystem outFs = FileSystems.newFileSystem(outputJar)){
|
FileSystem outFs = FileSystems.newFileSystem(outputJar, Map.of("create", "true"))) {
|
||||||
Files.walkFileTree(inFs.getPath(""), new SimpleFileVisitor<>() {
|
Files.walkFileTree(inFs.getPath("/"), new SimpleFileVisitor<>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) throws IOException {
|
public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes) throws IOException {
|
||||||
|
|
||||||
|
System.out.println(path);
|
||||||
if (path.getFileName().toString().endsWith(".class")) {
|
if (path.getFileName().toString().endsWith(".class")) {
|
||||||
Path newClass = outFs.getPath(path.toString());
|
String className = path.getFileName().toString().substring(0, path.getFileName().toString().lastIndexOf("."));
|
||||||
|
Path result = outFs.getPath(path.toString()).resolveSibling(data.classes().getOrDefault(className, className)+".class");
|
||||||
|
System.out.println("remapping: "+path);
|
||||||
|
Path newClass = result.toAbsolutePath();
|
||||||
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);
|
||||||
reader.accept(new ClassRemapper(writer, mapper), 0);
|
reader.accept(new ClassRemapper(writer, mapper), 0);
|
||||||
|
|
||||||
|
Files.createDirectories(result.getParent());
|
||||||
Files.write(newClass, writer.toByteArray());
|
Files.write(newClass, writer.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
Files.copy(path, outFs.getPath(path.toString()));
|
Path result = outFs.getPath(path.toString()).toAbsolutePath();
|
||||||
|
Files.createDirectories(result.getParent());
|
||||||
|
Files.copy(path, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
|
|
Loading…
Reference in a new issue