reindent ProguardParser, allow for mojmap caching and add .editorconfig
All checks were successful
Publish to snapshot maven / build (push) Successful in 13s

This commit is contained in:
moehreag 2024-05-19 15:14:00 +02:00
parent 8ce3afa7d6
commit 087234d3f9
4 changed files with 110 additions and 81 deletions

9
.editorconfig Normal file
View file

@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true
indent_style = tab

View file

@ -25,7 +25,7 @@ import org.objectweb.asm.commons.ClassRemapper;
public class NonsenseRemapper {
public static void run(String minecraftVersion, Path inputJar, Path outputJar, boolean skipMetaInf, boolean renameParameters) throws IOException, InterruptedException {
MappingData data = ProguardParser.read(MojmapProvider.get(minecraftVersion).orElseThrow()).reverse();
MappingData data = ProguardParser.read(MojmapProvider.get(minecraftVersion, outputJar.resolveSibling("client-"+minecraftVersion+".txt")).orElseThrow()).reverse();
Mapper mapper = new Mapper(data);

View file

@ -1,7 +1,7 @@
package org.ecorous.esnesnon.nonsense_remapper.parser;
import org.ecorous.esnesnon.nonsense_remapper.api.data.Member;
import org.ecorous.esnesnon.nonsense_remapper.api.data.MappingData;
import org.ecorous.esnesnon.nonsense_remapper.api.data.Member;
public class ProguardParser {

View file

@ -4,12 +4,24 @@ import com.google.gson.*;
import org.ecorous.esnesnon.nonsense_remapper.Constants;
import org.ecorous.esnesnon.nonsense_remapper.HttpHelper;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
public class MojmapProvider {
public static Optional<String> get(String gameVersion) {
return HttpHelper.getJson(Constants.VERSION_MANIFEST).map(manifest -> {
public static Optional<String> get(String gameVersion, Path cacheFile) {
if (Files.exists(cacheFile)){
try {
return Optional.of(Files.readString(cacheFile, StandardCharsets.UTF_8));
} catch (IOException e) {
// TODO
e.printStackTrace();
}
}
return HttpHelper.getJson(Constants.VERSION_MANIFEST).flatMap(manifest -> {
String versionName;
if (gameVersion.startsWith("latest-")) {
versionName = manifest.get("latest").getAsJsonObject().get(gameVersion.split("-")[1]).getAsString();
@ -27,10 +39,18 @@ public class MojmapProvider {
String mappingsUrl = versionManifest
.get("downloads").getAsJsonObject().get("client_mappings").getAsJsonObject().get("url").getAsString();
return HttpHelper.getString(mappingsUrl).orElseThrow();
return HttpHelper.getString(mappingsUrl).map(s -> {
try {
Files.writeString(cacheFile, s);
} catch (IOException e) {
// TODO
e.printStackTrace();
}
return s;
});
}
}
return null;
return Optional.empty();
});
}