diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/command')
6 files changed, 37 insertions, 17 deletions
diff --git a/src/main/java/cuchaz/enigma/command/CheckMappingsCommand.java b/src/main/java/cuchaz/enigma/command/CheckMappingsCommand.java index 08e73e6..9d238e3 100644 --- a/src/main/java/cuchaz/enigma/command/CheckMappingsCommand.java +++ b/src/main/java/cuchaz/enigma/command/CheckMappingsCommand.java | |||
| @@ -5,6 +5,7 @@ import cuchaz.enigma.EnigmaProject; | |||
| 5 | import cuchaz.enigma.ProgressListener; | 5 | import cuchaz.enigma.ProgressListener; |
| 6 | import cuchaz.enigma.analysis.index.JarIndex; | 6 | import cuchaz.enigma.analysis.index.JarIndex; |
| 7 | import cuchaz.enigma.translation.mapping.EntryMapping; | 7 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 8 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 8 | import cuchaz.enigma.translation.mapping.serde.MappingFormat; | 9 | import cuchaz.enigma.translation.mapping.serde.MappingFormat; |
| 9 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 10 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 10 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 11 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| @@ -43,7 +44,9 @@ public class CheckMappingsCommand extends Command { | |||
| 43 | System.out.println("Reading mappings..."); | 44 | System.out.println("Reading mappings..."); |
| 44 | 45 | ||
| 45 | MappingFormat format = chooseEnigmaFormat(fileMappings); | 46 | MappingFormat format = chooseEnigmaFormat(fileMappings); |
| 46 | EntryTree<EntryMapping> mappings = format.read(fileMappings, ProgressListener.none()); | 47 | MappingSaveParameters saveParameters = enigma.getProfile().getMappingSaveParameters(); |
| 48 | |||
| 49 | EntryTree<EntryMapping> mappings = format.read(fileMappings, ProgressListener.none(), saveParameters); | ||
| 47 | project.setMappings(mappings); | 50 | project.setMappings(mappings); |
| 48 | 51 | ||
| 49 | JarIndex idx = project.getJarIndex(); | 52 | JarIndex idx = project.getJarIndex(); |
diff --git a/src/main/java/cuchaz/enigma/command/Command.java b/src/main/java/cuchaz/enigma/command/Command.java index 41d7bfa..d53ed6e 100644 --- a/src/main/java/cuchaz/enigma/command/Command.java +++ b/src/main/java/cuchaz/enigma/command/Command.java | |||
| @@ -4,6 +4,7 @@ import cuchaz.enigma.Enigma; | |||
| 4 | import cuchaz.enigma.EnigmaProject; | 4 | import cuchaz.enigma.EnigmaProject; |
| 5 | import cuchaz.enigma.ProgressListener; | 5 | import cuchaz.enigma.ProgressListener; |
| 6 | import cuchaz.enigma.translation.mapping.EntryMapping; | 6 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 7 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 7 | import cuchaz.enigma.translation.mapping.serde.MappingFormat; | 8 | import cuchaz.enigma.translation.mapping.serde.MappingFormat; |
| 8 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 9 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 9 | 10 | ||
| @@ -35,7 +36,10 @@ public abstract class Command { | |||
| 35 | 36 | ||
| 36 | if (fileMappings != null) { | 37 | if (fileMappings != null) { |
| 37 | System.out.println("Reading mappings..."); | 38 | System.out.println("Reading mappings..."); |
| 38 | EntryTree<EntryMapping> mappings = chooseEnigmaFormat(fileMappings).read(fileMappings, progress); | 39 | |
| 40 | MappingSaveParameters saveParameters = enigma.getProfile().getMappingSaveParameters(); | ||
| 41 | EntryTree<EntryMapping> mappings = chooseEnigmaFormat(fileMappings).read(fileMappings, progress, saveParameters); | ||
| 42 | |||
| 39 | project.setMappings(mappings); | 43 | project.setMappings(mappings); |
| 40 | } | 44 | } |
| 41 | 45 | ||
diff --git a/src/main/java/cuchaz/enigma/command/ComposeMappingsCommand.java b/src/main/java/cuchaz/enigma/command/ComposeMappingsCommand.java index 1f6a069..f57f1fa 100644 --- a/src/main/java/cuchaz/enigma/command/ComposeMappingsCommand.java +++ b/src/main/java/cuchaz/enigma/command/ComposeMappingsCommand.java | |||
| @@ -2,6 +2,8 @@ package cuchaz.enigma.command; | |||
| 2 | 2 | ||
| 3 | import cuchaz.enigma.throwables.MappingParseException; | 3 | import cuchaz.enigma.throwables.MappingParseException; |
| 4 | import cuchaz.enigma.translation.mapping.EntryMapping; | 4 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 5 | import cuchaz.enigma.translation.mapping.MappingFileNameFormat; | ||
| 6 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 5 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 7 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 6 | import cuchaz.enigma.utils.Utils; | 8 | import cuchaz.enigma.utils.Utils; |
| 7 | 9 | ||
| @@ -26,12 +28,14 @@ public class ComposeMappingsCommand extends Command { | |||
| 26 | 28 | ||
| 27 | @Override | 29 | @Override |
| 28 | public void run(String... args) throws IOException, MappingParseException { | 30 | public void run(String... args) throws IOException, MappingParseException { |
| 29 | EntryTree<EntryMapping> left = MappingCommandsUtil.read(args[0], Paths.get(args[1])); | 31 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); |
| 30 | EntryTree<EntryMapping> right = MappingCommandsUtil.read(args[2], Paths.get(args[3])); | 32 | |
| 33 | EntryTree<EntryMapping> left = MappingCommandsUtil.read(args[0], Paths.get(args[1]), saveParameters); | ||
| 34 | EntryTree<EntryMapping> right = MappingCommandsUtil.read(args[2], Paths.get(args[3]), saveParameters); | ||
| 31 | EntryTree<EntryMapping> result = MappingCommandsUtil.compose(left, right, args[6].equals("left") || args[6].equals("both"), args[6].equals("right") || args[6].equals("both")); | 35 | EntryTree<EntryMapping> result = MappingCommandsUtil.compose(left, right, args[6].equals("left") || args[6].equals("both"), args[6].equals("right") || args[6].equals("both")); |
| 32 | 36 | ||
| 33 | Path output = Paths.get(args[5]); | 37 | Path output = Paths.get(args[5]); |
| 34 | Utils.delete(output); | 38 | Utils.delete(output); |
| 35 | MappingCommandsUtil.write(result, args[4], output); | 39 | MappingCommandsUtil.write(result, args[4], output, saveParameters); |
| 36 | } | 40 | } |
| 37 | } | 41 | } |
diff --git a/src/main/java/cuchaz/enigma/command/ConvertMappingsCommand.java b/src/main/java/cuchaz/enigma/command/ConvertMappingsCommand.java index 775bd3e..689df02 100644 --- a/src/main/java/cuchaz/enigma/command/ConvertMappingsCommand.java +++ b/src/main/java/cuchaz/enigma/command/ConvertMappingsCommand.java | |||
| @@ -2,6 +2,8 @@ package cuchaz.enigma.command; | |||
| 2 | 2 | ||
| 3 | import cuchaz.enigma.throwables.MappingParseException; | 3 | import cuchaz.enigma.throwables.MappingParseException; |
| 4 | import cuchaz.enigma.translation.mapping.EntryMapping; | 4 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 5 | import cuchaz.enigma.translation.mapping.MappingFileNameFormat; | ||
| 6 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 5 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 7 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 6 | import cuchaz.enigma.utils.Utils; | 8 | import cuchaz.enigma.utils.Utils; |
| 7 | 9 | ||
| @@ -26,10 +28,12 @@ public class ConvertMappingsCommand extends Command { | |||
| 26 | 28 | ||
| 27 | @Override | 29 | @Override |
| 28 | public void run(String... args) throws IOException, MappingParseException { | 30 | public void run(String... args) throws IOException, MappingParseException { |
| 29 | EntryTree<EntryMapping> mappings = MappingCommandsUtil.read(args[0], Paths.get(args[1])); | 31 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); |
| 32 | |||
| 33 | EntryTree<EntryMapping> mappings = MappingCommandsUtil.read(args[0], Paths.get(args[1]), saveParameters); | ||
| 30 | 34 | ||
| 31 | Path output = Paths.get(args[3]); | 35 | Path output = Paths.get(args[3]); |
| 32 | Utils.delete(output); | 36 | Utils.delete(output); |
| 33 | MappingCommandsUtil.write(mappings, args[2], output); | 37 | MappingCommandsUtil.write(mappings, args[2], output, saveParameters); |
| 34 | } | 38 | } |
| 35 | } | 39 | } |
diff --git a/src/main/java/cuchaz/enigma/command/InvertMappingsCommand.java b/src/main/java/cuchaz/enigma/command/InvertMappingsCommand.java index bfe8308..cd11e2e 100644 --- a/src/main/java/cuchaz/enigma/command/InvertMappingsCommand.java +++ b/src/main/java/cuchaz/enigma/command/InvertMappingsCommand.java | |||
| @@ -2,6 +2,8 @@ package cuchaz.enigma.command; | |||
| 2 | 2 | ||
| 3 | import cuchaz.enigma.throwables.MappingParseException; | 3 | import cuchaz.enigma.throwables.MappingParseException; |
| 4 | import cuchaz.enigma.translation.mapping.EntryMapping; | 4 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 5 | import cuchaz.enigma.translation.mapping.MappingFileNameFormat; | ||
| 6 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 5 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 7 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 6 | import cuchaz.enigma.utils.Utils; | 8 | import cuchaz.enigma.utils.Utils; |
| 7 | 9 | ||
| @@ -26,11 +28,13 @@ public class InvertMappingsCommand extends Command { | |||
| 26 | 28 | ||
| 27 | @Override | 29 | @Override |
| 28 | public void run(String... args) throws IOException, MappingParseException { | 30 | public void run(String... args) throws IOException, MappingParseException { |
| 29 | EntryTree<EntryMapping> source = MappingCommandsUtil.read(args[0], Paths.get(args[1])); | 31 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); |
| 32 | |||
| 33 | EntryTree<EntryMapping> source = MappingCommandsUtil.read(args[0], Paths.get(args[1]), saveParameters); | ||
| 30 | EntryTree<EntryMapping> result = MappingCommandsUtil.invert(source); | 34 | EntryTree<EntryMapping> result = MappingCommandsUtil.invert(source); |
| 31 | 35 | ||
| 32 | Path output = Paths.get(args[3]); | 36 | Path output = Paths.get(args[3]); |
| 33 | Utils.delete(output); | 37 | Utils.delete(output); |
| 34 | MappingCommandsUtil.write(result, args[2], output); | 38 | MappingCommandsUtil.write(result, args[2], output, saveParameters); |
| 35 | } | 39 | } |
| 36 | } | 40 | } |
diff --git a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java index 03d9ab7..8384e4e 100644 --- a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java +++ b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java | |||
| @@ -5,6 +5,7 @@ import cuchaz.enigma.throwables.MappingParseException; | |||
| 5 | import cuchaz.enigma.translation.MappingTranslator; | 5 | import cuchaz.enigma.translation.MappingTranslator; |
| 6 | import cuchaz.enigma.translation.Translator; | 6 | import cuchaz.enigma.translation.Translator; |
| 7 | import cuchaz.enigma.translation.mapping.EntryMapping; | 7 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 8 | import cuchaz.enigma.translation.mapping.MappingSaveParameters; | ||
| 8 | import cuchaz.enigma.translation.mapping.VoidEntryResolver; | 9 | import cuchaz.enigma.translation.mapping.VoidEntryResolver; |
| 9 | import cuchaz.enigma.translation.mapping.serde.*; | 10 | import cuchaz.enigma.translation.mapping.serde.*; |
| 10 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 11 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| @@ -91,13 +92,13 @@ public final class MappingCommandsUtil { | |||
| 91 | return result; | 92 | return result; |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | public static EntryTree<EntryMapping> read(String type, Path path) throws MappingParseException, IOException { | 95 | public static EntryTree<EntryMapping> read(String type, Path path, MappingSaveParameters saveParameters) throws MappingParseException, IOException { |
| 95 | if (type.equals("enigma")) { | 96 | if (type.equals("enigma")) { |
| 96 | return EnigmaMappingsReader.DIRECTORY.read(path, ProgressListener.none()); | 97 | return EnigmaMappingsReader.DIRECTORY.read(path, ProgressListener.none(), saveParameters); |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 99 | if (type.equals("tiny")) { | 100 | if (type.equals("tiny")) { |
| 100 | return TinyMappingsReader.INSTANCE.read(path, ProgressListener.none()); | 101 | return TinyMappingsReader.INSTANCE.read(path, ProgressListener.none(), saveParameters); |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | MappingFormat format = null; | 104 | MappingFormat format = null; |
| @@ -106,15 +107,15 @@ public final class MappingCommandsUtil { | |||
| 106 | } catch (IllegalArgumentException ignored) {} | 107 | } catch (IllegalArgumentException ignored) {} |
| 107 | 108 | ||
| 108 | if (format != null) { | 109 | if (format != null) { |
| 109 | return format.getReader().read(path, ProgressListener.none()); | 110 | return format.getReader().read(path, ProgressListener.none(), saveParameters); |
| 110 | } | 111 | } |
| 111 | 112 | ||
| 112 | throw new IllegalArgumentException("no reader for " + type); | 113 | throw new IllegalArgumentException("no reader for " + type); |
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | public static void write(EntryTree<EntryMapping> mappings, String type, Path path) { | 116 | public static void write(EntryTree<EntryMapping> mappings, String type, Path path, MappingSaveParameters saveParameters) { |
| 116 | if (type.equals("enigma")) { | 117 | if (type.equals("enigma")) { |
| 117 | EnigmaMappingsWriter.DIRECTORY.write(mappings, path, ProgressListener.none()); | 118 | EnigmaMappingsWriter.DIRECTORY.write(mappings, path, ProgressListener.none(), saveParameters); |
| 118 | return; | 119 | return; |
| 119 | } | 120 | } |
| 120 | 121 | ||
| @@ -125,7 +126,7 @@ public final class MappingCommandsUtil { | |||
| 125 | throw new IllegalArgumentException("specify column names as 'tiny:from_column:to_column'"); | 126 | throw new IllegalArgumentException("specify column names as 'tiny:from_column:to_column'"); |
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | new TinyMappingsWriter(split[1], split[2]).write(mappings, path, ProgressListener.none()); | 129 | new TinyMappingsWriter(split[1], split[2]).write(mappings, path, ProgressListener.none(), saveParameters); |
| 129 | return; | 130 | return; |
| 130 | } | 131 | } |
| 131 | 132 | ||
| @@ -135,7 +136,7 @@ public final class MappingCommandsUtil { | |||
| 135 | } catch (IllegalArgumentException ignored) {} | 136 | } catch (IllegalArgumentException ignored) {} |
| 136 | 137 | ||
| 137 | if (format != null) { | 138 | if (format != null) { |
| 138 | format.getWriter().write(mappings, path, ProgressListener.none()); | 139 | format.getWriter().write(mappings, path, ProgressListener.none(), saveParameters); |
| 139 | return; | 140 | return; |
| 140 | } | 141 | } |
| 141 | 142 | ||