Restructure and simplify some stuff #1

Merged
kode merged 2 commits from TheKodeToad/restructure into main 2024-05-12 07:57:11 -04:00
6 changed files with 17 additions and 16 deletions
Showing only changes of commit 7201b56658 - Show all commits

View file

@ -1,7 +1,7 @@
package io.github.moehreag.mojmap_patcher; package io.github.moehreag.mojmap_patcher;
import io.github.moehreag.mojmap_patcher.load.MojmapLoader; import io.github.moehreag.mojmap_patcher.provider.MojmapProvider;
import io.github.moehreag.mojmap_patcher.parser.MojmapParser; import io.github.moehreag.mojmap_patcher.format.proguard.ProguardParser;
public class MojMapPatcher { public class MojMapPatcher {
@ -12,7 +12,7 @@ public class MojMapPatcher {
} else { } else {
version = args[0]; version = args[0];
} }
MojmapLoader.get(version).map(MojmapParser::read).ifPresent(s -> { MojmapProvider.get(version).map(ProguardParser::read).ifPresent(s -> {
//s.getClassFields().keySet().forEach(System.out::println); //s.getClassFields().keySet().forEach(System.out::println);
s.getClassFields().get("net.minecraft.client.Minecraft").forEach((s1, s2) -> System.out.println(s1 + " -> " + s2)); s.getClassFields().get("net.minecraft.client.Minecraft").forEach((s1, s2) -> System.out.println(s1 + " -> " + s2));
}); });

View file

@ -1,6 +1,6 @@
package io.github.moehreag.mojmap_patcher.api; package io.github.moehreag.mojmap_patcher.api;
import io.github.moehreag.mojmap_patcher.api.data.Data; import io.github.moehreag.mojmap_patcher.api.data.MappingData;
import io.github.moehreag.mojmap_patcher.api.data.Field; import io.github.moehreag.mojmap_patcher.api.data.Field;
import io.github.moehreag.mojmap_patcher.api.data.Method; import io.github.moehreag.mojmap_patcher.api.data.Method;
import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.commons.Remapper;
@ -11,10 +11,10 @@ import java.util.Optional;
public class Mapper extends Remapper { public class Mapper extends Remapper {
private Data data; private MappingData data;
public static Mapper load() { public static Mapper load() {
throw new UnsupportedOperationException("TODO");
} }
public String mapClass(String name) { public String mapClass(String name) {

View file

@ -2,7 +2,7 @@ package io.github.moehreag.mojmap_patcher.api.data;
import java.util.Map; import java.util.Map;
public interface Data { public interface MappingData {
Map<String, String> getClasses(); Map<String, String> getClasses();

View file

@ -1,6 +1,7 @@
package io.github.moehreag.mojmap_patcher.data; package io.github.moehreag.mojmap_patcher.format.proguard;
import io.github.moehreag.mojmap_patcher.api.data.Field; import io.github.moehreag.mojmap_patcher.api.data.Field;
import io.github.moehreag.mojmap_patcher.api.data.MappingData;
import io.github.moehreag.mojmap_patcher.api.data.Method; import io.github.moehreag.mojmap_patcher.api.data.Method;
import lombok.Data; import lombok.Data;
@ -8,7 +9,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Data @Data
public class MojmapData implements io.github.moehreag.mojmap_patcher.api.data.Data { public class ProguardData implements MappingData {
private final Map<String, String> classes = new HashMap<>(); private final Map<String, String> classes = new HashMap<>();
private final Map<String, Map<Method, Method>> classMethods = new HashMap<>(); private final Map<String, Map<Method, Method>> classMethods = new HashMap<>();

View file

@ -1,18 +1,18 @@
package io.github.moehreag.mojmap_patcher.parser; package io.github.moehreag.mojmap_patcher.format.proguard;
import io.github.moehreag.mojmap_patcher.Constants; import io.github.moehreag.mojmap_patcher.Constants;
import io.github.moehreag.mojmap_patcher.api.data.Field; import io.github.moehreag.mojmap_patcher.api.data.Field;
import io.github.moehreag.mojmap_patcher.api.data.Method; import io.github.moehreag.mojmap_patcher.api.data.Method;
import io.github.moehreag.mojmap_patcher.data.MojmapData; import io.github.moehreag.mojmap_patcher.format.proguard.ProguardData;
import java.util.HashMap; import java.util.HashMap;
public class MojmapParser { public class ProguardParser {
public static MojmapData read(String mappings) { public static ProguardData read(String mappings) {
String[] lines = mappings.split("\n"); String[] lines = mappings.split("\n");
MojmapData data = new MojmapData(); ProguardData data = new ProguardData();
String currentClass = null; String currentClass = null;
for (String line : lines) { for (String line : lines) {
if (line.startsWith("#")) { // Filter out comments if (line.startsWith("#")) { // Filter out comments

View file

@ -1,4 +1,4 @@
package io.github.moehreag.mojmap_patcher.load; package io.github.moehreag.mojmap_patcher.provider;
import com.google.gson.*; import com.google.gson.*;
import io.github.moehreag.mojmap_patcher.Constants; import io.github.moehreag.mojmap_patcher.Constants;
@ -6,7 +6,7 @@ import io.github.moehreag.mojmap_patcher.HttpHelper;
import java.util.Optional; import java.util.Optional;
public class MojmapLoader { public class MojmapProvider {
public static Optional<String> get(String gameVersion) { public static Optional<String> get(String gameVersion) {
return HttpHelper.getJson(Constants.VERSION_MANIFEST).map(manifest -> { return HttpHelper.getJson(Constants.VERSION_MANIFEST).map(manifest -> {