add support for handling fscript
This commit is contained in:
parent
4720c3e217
commit
3c6b3e84ba
|
@ -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()));
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user