feat: updated to new mapper library version

This commit is contained in:
zaaarf 2023-09-01 12:17:37 +02:00
parent ffbcdaeee1
commit 3e2f0a6bcf
No known key found for this signature in database
GPG key ID: 6445A5CD15E5B40C
6 changed files with 18 additions and 20 deletions

View file

@ -8,8 +8,7 @@ archivesBaseName = 'mapping-writer'
version = gitVersion() version = gitVersion()
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar() withSourcesJar()
withJavadocJar() withJavadocJar()
} }
@ -21,7 +20,7 @@ repositories {
dependencies { dependencies {
implementation 'commons-cli:commons-cli:1.5.0' implementation 'commons-cli:commons-cli:1.5.0'
implementation 'ftbsc.lll:mapper:0.2.3' implementation 'ftbsc.lll:mapper:0.3.0'
implementation 'com.google.auto.service:auto-service-annotations:1.1.0' implementation 'com.google.auto.service:auto-service-annotations:1.1.0'
annotationProcessor 'com.google.auto.service:auto-service:1.1.0' annotationProcessor 'com.google.auto.service:auto-service:1.1.0'
} }

View file

@ -1,6 +1,6 @@
package ftbsc.lll.mapper.writer; package ftbsc.lll.mapper.writer;
import ftbsc.lll.mapper.IMapper; import ftbsc.lll.mapper.tools.Mapper;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -15,10 +15,10 @@ public interface IWriter {
String uniqueId(); String uniqueId();
/** /**
* Writes in a {@link PrintWriter} the contents of a {@link IMapper}. * Writes in a {@link PrintWriter} the contents of a {@link Mapper}.
* @param mapper the mapper * @param mapper the mapper
* @param writer the writer * @param writer the writer
* @param args various arguments which the writers may need * @param args various arguments which the writers may need
*/ */
void write(IMapper mapper, PrintWriter writer, String... args); void write(Mapper mapper, PrintWriter writer, String... args);
} }

View file

@ -1,7 +1,7 @@
package ftbsc.lll.mapper.writer; package ftbsc.lll.mapper.writer;
import ftbsc.lll.mapper.IMapper;
import ftbsc.lll.mapper.MapperProvider; import ftbsc.lll.mapper.MapperProvider;
import ftbsc.lll.mapper.tools.Mapper;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import java.io.File; import java.io.File;
@ -16,7 +16,7 @@ import java.util.*;
public class MappingWriter { public class MappingWriter {
/** /**
* The main function, must be passed exactly two arguments * The main function.
* @param args the command line arguments * @param args the command line arguments
* @throws IOException if something goes wrong while writing the file * @throws IOException if something goes wrong while writing the file
* @throws ParseException if something goes wrong while parsin arguments * @throws ParseException if something goes wrong while parsin arguments
@ -43,7 +43,7 @@ public class MappingWriter {
args = newArgs; args = newArgs;
} else customArgs = new String[0]; } else customArgs = new String[0];
if(args.length < 4) { if(args.length < 3) {
System.err.println("Bad argument count!"); System.err.println("Bad argument count!");
System.err.println("java -jar mapping-writer.jar [-r] <location> <format> <output> [-a <custom args]"); System.err.println("java -jar mapping-writer.jar [-r] <location> <format> <output> [-a <custom args]");
return; return;
@ -51,10 +51,9 @@ public class MappingWriter {
//load the mapper //load the mapper
List<String> lines = MapperProvider.fetchFromLocalOrRemote(args[0]); List<String> lines = MapperProvider.fetchFromLocalOrRemote(args[0]);
IMapper mapper = MapperProvider.getMapper(lines); Mapper mapper = !cmdLine.hasOption("reverse")
mapper.populate(lines, false); ? MapperProvider.getMapper(lines).getMapper(lines, false)
if(cmdLine.hasOption("reverse")) : MapperProvider.getMapper(lines).getInvertedMapper(lines, false);
mapper = mapper.getInverted();
//load the writers //load the writers
Map<String, IWriter> writerMap = new HashMap<>(); Map<String, IWriter> writerMap = new HashMap<>();

View file

@ -1,7 +1,7 @@
package ftbsc.lll.mapper.writer.impl; package ftbsc.lll.mapper.writer.impl;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.lll.mapper.IMapper; import ftbsc.lll.mapper.tools.Mapper;
import ftbsc.lll.mapper.tools.MappingUtils; import ftbsc.lll.mapper.tools.MappingUtils;
import ftbsc.lll.mapper.tools.data.FieldData; import ftbsc.lll.mapper.tools.data.FieldData;
import ftbsc.lll.mapper.tools.data.MethodData; import ftbsc.lll.mapper.tools.data.MethodData;
@ -22,13 +22,13 @@ public class SRGWriter implements IWriter {
} }
@Override @Override
public void write(IMapper mapper, PrintWriter writer, String... ignored) { public void write(Mapper mapper, PrintWriter writer, String... ignored) {
List<FieldData> fieldData = new ArrayList<>(); List<FieldData> fieldData = new ArrayList<>();
List<MethodData> methodData = new ArrayList<>(); List<MethodData> methodData = new ArrayList<>();
//print classes and save rest for later //print classes and save rest for later
mapper.getRawMappings().forEach((name, data) -> { mapper.getRawMappings().forEach((name, data) -> {
writer.printf("CL: %s, %s\n", name, data.nameMapped); writer.printf("CL: %s %s\n", name, data.nameMapped);
fieldData.addAll(data.getFields().values()); fieldData.addAll(data.getFields().values());
methodData.addAll(data.getMethods().values()); methodData.addAll(data.getMethods().values());
}); });

View file

@ -1,7 +1,7 @@
package ftbsc.lll.mapper.writer.impl; package ftbsc.lll.mapper.writer.impl;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.lll.mapper.IMapper; import ftbsc.lll.mapper.tools.Mapper;
import ftbsc.lll.mapper.writer.IWriter; import ftbsc.lll.mapper.writer.IWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -18,7 +18,7 @@ public class TSRGWriter implements IWriter {
} }
@Override @Override
public void write(IMapper mapper, PrintWriter writer, String... args) { public void write(Mapper mapper, PrintWriter writer, String... args) {
if(args.length < 2) if(args.length < 2)
args = new String[] { "left", "right" }; args = new String[] { "left", "right" };
writer.printf("tsrg2 %s %s\n", args[0], args[1]); writer.printf("tsrg2 %s %s\n", args[0], args[1]);

View file

@ -1,7 +1,7 @@
package ftbsc.lll.mapper.writer.impl; package ftbsc.lll.mapper.writer.impl;
import com.google.auto.service.AutoService; import com.google.auto.service.AutoService;
import ftbsc.lll.mapper.IMapper; import ftbsc.lll.mapper.tools.Mapper;
import ftbsc.lll.mapper.writer.IWriter; import ftbsc.lll.mapper.writer.IWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -18,7 +18,7 @@ public class TinyV2Writer implements IWriter {
} }
@Override @Override
public void write(IMapper mapper, PrintWriter writer, String... args) { public void write(Mapper mapper, PrintWriter writer, String... args) {
writer.printf("tiny\t2\t0\t%s\t%s", args[0], args[1]); writer.printf("tiny\t2\t0\t%s\t%s", args[0], args[1]);
mapper.getRawMappings().forEach((name, data) -> { mapper.getRawMappings().forEach((name, data) -> {
writer.printf("c\t%s\t%s\n", name, data.nameMapped); writer.printf("c\t%s\t%s\n", name, data.nameMapped);