add support for handling fscript

This commit is contained in:
Wirlaburla 2024-07-20 23:17:49 -05:00
parent 4720c3e217
commit 3c6b3e84ba
2 changed files with 6 additions and 27 deletions

View File

@ -203,6 +203,9 @@ public class Clifford implements ActionListener {
if (new File(directory.getAbsolutePath() + "/pack.png").exists()) {
zip.addFile(new File(directory.getAbsolutePath() + "/pack.png"));
}
if (new File(directory.getAbsolutePath() + "/fscript").exists()) {
zip.addFile(new File(directory.getAbsolutePath() + "/fscript"));
}
JSONObject container = new JSONObject();
container.put("version", Integer.parseInt(fVersion.getText()));

View File

@ -154,33 +154,9 @@ public class Gonzo {
consoleDisplay.append("Firestar is extracting " + m.friendlyName + " by " + m.author + "\n");
new ZipFile(System.getProperty("user.home") + "/.firestar/mods/" + m.path).extractAll(System.getProperty("user.home") + "/.firestar/temp/");
try (Stream<Path> walkStream = Files.walk(Paths.get(System.getProperty("user.home") + "/.firestar/temp/"))) {
walkStream.filter(p -> p.toFile().isFile()).forEach(f -> {
if (f.toString().endsWith(".patch")) {
System.out.println("Patching " + f.toString() + "...");
consoleDisplay.append("Patching " + f.toString() + "...\n");
String mainFile = f.toString().substring(0, f.toString().length() - 6);
try {
List<String> original = Files.readAllLines(new File(mainFile).toPath());
List<String> patched = Files.readAllLines(f);
Patch<String> patch = UnifiedDiffUtils.parseUnifiedDiff(patched);
List<String> result = DiffUtils.patch(original, patch);
try (FileWriter fileWriter = new FileWriter(mainFile)) {
for (String str : result) {
fileWriter.write(str + "\r\n");
}
}
new File(f.toString()).delete();
} catch (Exception ex) {
Logger.getLogger(Gonzo.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex.getMessage());
consoleDisplay.append("CRITICAL FAILURE: " + ex.getMessage());
}
}
});
File fscript = new File(Main.inpath + "temp/fscript");
if (fscript.exists()) {
new Rizzo(fscript, Main.inpath + "temp/"); // Lets rizz this mod up
}
if (new File(System.getProperty("user.home") + "/.firestar/temp/delete.txt").isFile()) {