@@ -67,7 +67,7 @@ private static void install(String[] ids) {
6767 String slug = (String ) json .get ("slug" );
6868 String name = (String ) json .get ("name" );
6969 System .out .println (Ansi .ansi ().fg (Ansi .Color .YELLOW ).a ("Installing " ).a (name ).a ("..." ).reset ());
70- File packFolder = new File (Config .modpackDir .getPath () + File .separator + slug + "_" + id + (fileId != null ? "_" + fileId : "" ));
70+ File packFolder = new File (Config .modpackDir .getAbsolutePath () + File .separator + slug + "_" + id + (fileId != null ? "_" + fileId : "" ));
7171 if (packFolder .exists ()) {
7272 Scanner scanner = new Scanner (System .in );
7373 System .out .println (Ansi .ansi ().fg (Ansi .Color .YELLOW ).a ("Found old folder of " ).a (name ).a (". If you want to re-install while keeping your files, use \" repair\" instead." ).reset ());
@@ -82,15 +82,15 @@ private static void install(String[] ids) {
8282 }
8383 packFolder .mkdir ();
8484 String downloadUrl = ((String ) files .get ("downloadUrl" )).replaceFirst ("edge" , "media" );
85- String loc = Utils .downloadFile (downloadUrl , packFolder .getPath ());
85+ String loc = Utils .downloadFile (downloadUrl , packFolder .getAbsolutePath ());
8686 if (loc == null ) throw new SyncFailedException ("Failed to download modpack " + name );
8787 boolean success = Utils .unzip (loc );
8888 if (!success ) throw new FileSystemException ("Failed to extract modpack content of " + name );
8989 File manifest = new File (packFolder + File .separator + getManifestFile (files ));
9090 if (!manifest .exists ()) throw new FileNotFoundException ("Cannot find modpack manifest of " + name );
9191 JSONObject manifestJson = (JSONObject ) parser .parse (new FileReader (manifest ));
92- copyFromOverride (packFolder .getPath (), (String ) manifestJson .get ("overrides" ));
93- downloadMods (packFolder .getPath ());
92+ copyFromOverride (packFolder .getAbsolutePath (), (String ) manifestJson .get ("overrides" ));
93+ downloadMods (packFolder .getAbsolutePath ());
9494 String thumb = downloadThumb (json );
9595 genProfile (name , packFolder .getAbsolutePath (), thumb , getModVersion (manifestJson ));
9696 System .out .println (Ansi .ansi ().fg (Ansi .Color .GREEN ).a ("Finished download of " + name ).reset ());
@@ -303,7 +303,7 @@ private static void delete(String[] ids) {
303303 AtomicInteger failed = new AtomicInteger ();
304304 folders .forEach ((key , value ) -> {
305305 try {
306- FileUtils .deleteDirectory (new File (Config .modpackDir .getPath () + File .separator + key ));
306+ FileUtils .deleteDirectory (new File (Config .modpackDir .getAbsolutePath () + File .separator + key ));
307307 } catch (Exception e ) {
308308 e .printStackTrace ();
309309 failed .getAndIncrement ();
@@ -321,7 +321,7 @@ private static void list() {
321321 List <Ansi > modpack = new ArrayList <>();
322322 for (Map .Entry <Integer , String > entry : modpacks .entrySet ()) {
323323 String folderName = entry .getValue () + "_" + entry .getKey ();
324- File manifest = new File (Config .modpackDir .getPath () + File .separator + folderName + File .separator + "manifest.json" );
324+ File manifest = new File (Config .modpackDir .getAbsolutePath () + File .separator + folderName + File .separator + "manifest.json" );
325325 if (!manifest .exists () || !manifest .isFile ()) continue ;
326326 try {
327327 JSONObject json = (JSONObject ) parser .parse (new FileReader (manifest ));
@@ -362,18 +362,18 @@ private static void update(String[] ids, boolean force) {
362362 throw new NoSuchObjectException ("The ID " + id + " does not represent a modpack." );
363363 String name = (String ) json .get ("name" );
364364 System .out .println (Ansi .ansi ().fg (Ansi .Color .YELLOW ).a ("Updating " ).a (name ).a ("..." ).reset ());
365- File packFolder = new File (Config .modpackDir .getPath () + File .separator + slug + "_" + key );
365+ File packFolder = new File (Config .modpackDir .getAbsolutePath () + File .separator + slug + "_" + key );
366366 JSONObject latest = (JSONObject ) Utils .getLast ((JSONArray ) json .get ("latestFiles" ));
367367 String downloadUrl = ((String ) latest .get ("downloadUrl" )).replaceFirst ("edge" , "media" );
368- String loc = Utils .downloadFile (downloadUrl , packFolder .getPath ());
368+ String loc = Utils .downloadFile (downloadUrl , packFolder .getAbsolutePath ());
369369 if (loc == null ) throw new SyncFailedException ("Failed to download modpack " + name );
370370 boolean success = Utils .unzip (loc );
371371 if (!success ) throw new FileSystemException ("Failed to extract modpack content of " + name );
372372 File manifest = new File (packFolder + File .separator + "manifest.json" );
373373 if (!manifest .exists ()) throw new FileNotFoundException ("Cannot find modpack manifest of " + name );
374- if (force ) FileUtils .cleanDirectory (new File (packFolder .getPath () + File .separator + "mods" ));
375- copyFromOverride (packFolder .getPath (), (String ) ((JSONObject ) parser .parse (new FileReader (manifest ))).get ("overrides" ));
376- downloadMods (packFolder .getPath (), force );
374+ if (force ) FileUtils .cleanDirectory (new File (packFolder .getAbsolutePath () + File .separator + "mods" ));
375+ copyFromOverride (packFolder .getAbsolutePath (), (String ) ((JSONObject ) parser .parse (new FileReader (manifest ))).get ("overrides" ));
376+ downloadMods (packFolder .getAbsolutePath (), force );
377377 System .out .println (Ansi .ansi ().fg (Ansi .Color .GREEN ).a ("Finished download of " + name ).reset ());
378378 } catch (Exception e ) {
379379 e .printStackTrace ();
@@ -400,13 +400,13 @@ private static void convert(String[] ids) {
400400 }
401401 if (slug == null ) throw new NoSuchObjectException ("Cannot find modpack with name " + id );
402402 }
403- File packFolder = new File (Config .modpackDir .getPath () + File .separator + slug + "_" + key );
404- File manifest = new File (packFolder .getPath () + File .separator + "manifest.json" );
403+ File packFolder = new File (Config .modpackDir .getAbsolutePath () + File .separator + slug + "_" + key );
404+ File manifest = new File (packFolder .getAbsolutePath () + File .separator + "manifest.json" );
405405 if (!manifest .exists () || !manifest .isFile ())
406406 throw new FileNotFoundException ("Modpack is missing manifest. Cannot convert to profile." );
407407 FileUtils .moveDirectoryToDirectory (packFolder , Config .profileDir , true );
408- packFolder = new File (Config .profileDir .getPath () + File .separator + slug + "_" + key );
409- manifest = new File (packFolder .getPath () + File .separator + "manifest.json" );
408+ packFolder = new File (Config .profileDir .getAbsolutePath () + File .separator + slug + "_" + key );
409+ manifest = new File (packFolder .getAbsolutePath () + File .separator + "manifest.json" );
410410 JSONObject json = (JSONObject ) parser .parse (new FileReader (manifest ));
411411 JSONObject profile = new JSONObject ();
412412 JSONObject minecraft = (JSONObject ) json .get ("minecraft" );
@@ -415,7 +415,7 @@ private static void convert(String[] ids) {
415415 profile .put ("mcVer" , minecraft .get ("version" ));
416416 profile .put ("launcher" , launcher [0 ]);
417417 profile .put ("modVer" , launcher [1 ]);
418- PrintWriter pw = new PrintWriter (packFolder .getPath () + File .separator + "profile.json" );
418+ PrintWriter pw = new PrintWriter (packFolder .getAbsolutePath () + File .separator + "profile.json" );
419419 pw .write (profile .toJSONString ());
420420
421421 pw .flush ();
0 commit comments