summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/CommandMain.java
diff options
context:
space:
mode:
authorGravatar Thog2016-08-24 01:59:26 +0200
committerGravatar Thog2016-08-24 01:59:26 +0200
commit6e9934a442394a9d0a81404c7480b8001939d92b (patch)
tree28252cd87aae33ccc2da9f7c83dcf63db2f45578 /src/main/java/cuchaz/enigma/CommandMain.java
parentRevert Main.java (diff)
downloadenigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.tar.gz
enigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.tar.xz
enigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.zip
Add mapping converter to command line system
Diffstat (limited to 'src/main/java/cuchaz/enigma/CommandMain.java')
-rw-r--r--src/main/java/cuchaz/enigma/CommandMain.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/main/java/cuchaz/enigma/CommandMain.java b/src/main/java/cuchaz/enigma/CommandMain.java
index 0678458..54f2707 100644
--- a/src/main/java/cuchaz/enigma/CommandMain.java
+++ b/src/main/java/cuchaz/enigma/CommandMain.java
@@ -65,7 +65,10 @@ public class CommandMain {
65 protectify(args); 65 protectify(args);
66 } else if (command.equalsIgnoreCase("publify")) { 66 } else if (command.equalsIgnoreCase("publify")) {
67 publify(args); 67 publify(args);
68 } else { 68 } else if (command.equalsIgnoreCase("convertmappings")) {
69 convertMappings(args);
70 }
71 else {
69 throw new IllegalArgumentException("Command not recognized: " + command); 72 throw new IllegalArgumentException("Command not recognized: " + command);
70 } 73 }
71 } catch (IllegalArgumentException ex) { 74 } catch (IllegalArgumentException ex) {
@@ -82,6 +85,8 @@ public class CommandMain {
82 System.out.println("\t\tdeobfuscate <in jar> <out jar> [<mappings file>]"); 85 System.out.println("\t\tdeobfuscate <in jar> <out jar> [<mappings file>]");
83 System.out.println("\t\tdecompile <in jar> <out folder> [<mappings file>]"); 86 System.out.println("\t\tdecompile <in jar> <out folder> [<mappings file>]");
84 System.out.println("\t\tprotectify <in jar> <out jar>"); 87 System.out.println("\t\tprotectify <in jar> <out jar>");
88 System.out.println("\t\tpublify <in jar> <out jar>");
89 System.out.println("\t\tconvertmappings <enigma mappings> <converted mappings> <ENIGMA_FILE|ENIGMA_DIRECTORY|SRG_FILE>");
85 } 90 }
86 91
87 private static void decompile(String[] args) throws Exception { 92 private static void decompile(String[] args) throws Exception {
@@ -125,6 +130,27 @@ public class CommandMain {
125 return deobfuscator; 130 return deobfuscator;
126 } 131 }
127 132
133 private static void convertMappings(String[] args) throws Exception {
134 File fileMappings = getReadableFile(getArg(args, 1, "enigma mapping", true));
135 File result = getWritableFile(getArg(args, 2, "enigma mapping", true));
136 String name = getArg(args, 3, "format type", true);
137 Mappings.FormatType formatType = Mappings.FormatType.valueOf(name.toUpperCase());
138 if (formatType == null)
139 throw new IllegalArgumentException(name + "is not a valid mapping format!");
140 System.out.println("Reading mappings...");
141 Mappings mappings = new MappingsEnigmaReader().read(fileMappings);
142 System.out.println("Saving new mappings...");
143 switch (formatType)
144 {
145 case SRG_FILE:
146 mappings.saveSRGMappings(result);
147 break;
148 default:
149 mappings.saveEnigmaMappings(result, Mappings.FormatType.ENIGMA_FILE != formatType);
150 break;
151 }
152 }
153
128 private static String getArg(String[] args, int i, String name, boolean required) { 154 private static String getArg(String[] args, int i, String name, boolean required) {
129 if (i >= args.length) { 155 if (i >= args.length) {
130 if (required) { 156 if (required) {