4
0
Fork 0
mirror of https://github.com/Anvilcraft/modpacktools synced 2024-11-17 23:41:55 +01:00

AddMod.java ist now writing the json to the File correctly

This commit is contained in:
Timo Ley 2020-06-18 22:29:32 +02:00
parent 5179c3faee
commit 3d3f914d2c
2 changed files with 16 additions and 7 deletions

View file

@ -60,7 +60,6 @@ public class AddMod implements ICommand {
if(matcher.find()) { if(matcher.find()) {
fileID = Integer.parseInt(matcher.group(0)); fileID = Integer.parseInt(matcher.group(0));
} }
File manifestFile = new File(Main.CONFIG.JAR_LOCATION, Main.CONFIG.CONFIG.getPath(String.class, "Locations", "manifestFile"));
System.out.println("Reading Addonscript"); System.out.println("Reading Addonscript");
//Get Mods in manifest file //Get Mods in manifest file
//Check if Mod already exsits //Check if Mod already exsits
@ -86,12 +85,7 @@ public class AddMod implements ICommand {
version.relations = new ArrayList<>(); version.relations = new ArrayList<>();
} }
version.relations.add(rel); version.relations.add(rel);
//Overwrite Old Manifest File }catch(CurseException e) {
FileWriter manifestWriter = new FileWriter(manifestFile, false);
System.out.println("Printing Manifest");
json.write(manifestWriter);
manifestWriter.close();
}catch(CurseException | IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
}else { }else {
@ -104,6 +98,16 @@ public class AddMod implements ICommand {
} }
version.relations.add(rel); version.relations.add(rel);
} }
//Overwrite Old Manifest File
FileWriter manifestWriter = null;
try {
manifestWriter = new FileWriter(Main.MPJH.getFile(), false);
System.out.println("Printing Manifest");
json.write(manifestWriter);
manifestWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}else { }else {
return CommandReturn.fail("Syntax: addmod <curseforge url>"); return CommandReturn.fail("Syntax: addmod <curseforge url>");
} }

View file

@ -21,4 +21,9 @@ public class ModpackJsonHandler {
} }
return null; return null;
} }
public File getFile() {
return modpackJsonFile;
}
} }