Skip to content

Commit

Permalink
Manifest writer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Jun 27, 2021
1 parent 9bceabd commit e078aaa
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/net/ME1312/ForgeInstaller/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,27 @@ public static void main(String[] args) {
System.out.println("Cleaning MANIFEST.MF ...");
System.out.println();
StringBuilder edited = new StringBuilder();
String[] original = readAll(new InputStreamReader(zip)).replace("\r", "").replace("\n ", "").split("\n");
Pattern pattern = Pattern.compile("^(Manifest-Version|Main-Class):\\s*(.*)$");
String[] original = readAll(new InputStreamReader(zip)).replace("\r\n", "\n").replace("\n ", "").split("\n");
Pattern pattern = Pattern.compile("^(?:Manifest-Version|Main-Class):.*$");
for (String property : original) {
Matcher m = pattern.matcher(property);
if (m.find()) {
edited.append(m.group(1));
edited.append(": ");
edited.append(m.group(2));
edited.append(m.group());
edited.append('\n');
}
}
edited.append("Built-By: Minecraft Forge Installer Installer");
edited.append('\n');
zop.putNextEntry(new ZipEntry(path));
zop.write(edited.toString().getBytes(StandardCharsets.UTF_8));
} else if (path.startsWith("META-INF/") && path.endsWith(".SF")) {
System.out.println("Removing " + path.substring(9) + " ...");
System.out.println();
} else if (path.indexOf('/') == -1 && path.endsWith(".json")) {
System.out.println("Updating " + path + " ...");
JSONObject json = (JSONObject) convert(new JSONObject(readAll(new InputStreamReader(zip))));
System.out.println();
zop.putNextEntry(new ZipEntry(path));
zop.write(json.toString(4).getBytes(StandardCharsets.UTF_8));
zop.write(((JSONObject) convert(new JSONObject(readAll(new InputStreamReader(zip))))).toString(4).getBytes(StandardCharsets.UTF_8));
} else {
zop.putNextEntry(new ZipEntry(path));
byte[] b = new byte[4096];
Expand Down

0 comments on commit e078aaa

Please sign in to comment.