@@ -220,10 +220,7 @@ private static void add(String[] ids) {
220220 JSONObject json = (JSONObject ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + id );
221221 if (json == null || ((long ) ((JSONObject ) json .get ("categorySection" )).get ("gameCategoryId" )) != 6 ) throw new Exception ("The ID " +id +" does not represent a mod." );
222222 JSONArray files = (JSONArray ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + id + "/files" );
223- List f = (List ) files .stream ().filter (o -> {
224- JSONArray versions = (JSONArray ) ((JSONObject ) o ).get ("gameVersion" );
225- return versions .get (0 ).equals (config .get ("mcVer" )) && ((String ) versions .get (1 )).equalsIgnoreCase ((String ) config .get ("launcher" ));
226- }).collect (Collectors .toList ());
223+ List f = (List ) files .stream ().filter (o -> Utils .checkVersion ((JSONArray ) ((JSONObject ) o ).get ("gameVersion" ), config )).collect (Collectors .toList ());
227224 f .sort ((a , b ) -> (int ) ((long ) ((JSONObject ) b ).get ("id" ) - (long ) ((JSONObject ) a ).get ("id" )));
228225 if (f .size () < 1 ) throw new Exception ("No available file of " + id + " found for this profile." );
229226 JSONObject bestFile = (JSONObject ) f .get (0 );
@@ -440,18 +437,16 @@ private static void update(String[] args) {
440437 JSONObject json = (JSONObject ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + entry .getKey ());
441438 if (json == null || ((long ) ((JSONObject ) json .get ("categorySection" )).get ("gameCategoryId" )) != 6 ) throw new Exception ("The ID " +entry .getKey ()+" does not represent a mod." );
442439 JSONArray files = (JSONArray ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + entry .getKey () + "/files" );
443- List f = (List ) files .stream ().filter (o -> {
444- JSONArray versions = (JSONArray ) ((JSONObject ) o ).get ("gameVersion" );
445- return versions .get (0 ).equals (config .get ("mcVer" )) && ((String ) versions .get (1 )).equalsIgnoreCase ((String ) config .get ("launcher" ));
446- }).collect (Collectors .toList ());
440+ List f = (List ) files .stream ().filter (o -> Utils .checkVersion ((JSONArray ) ((JSONObject ) o ).get ("gameVersion" ), config )).collect (Collectors .toList ());
447441 f .sort ((a , b ) -> (int ) ((long ) ((JSONObject ) b ).get ("id" ) - (long ) ((JSONObject ) a ).get ("id" )));
448- if (f .size () < 1 ) throw new Exception ( "No available file of " + entry . getKey () + " found for this profile." ) ;
442+ if (f .size () < 1 ) continue ;
449443 JSONObject fjson = (JSONObject ) f .get (0 );
450444 if (((long ) fjson .get ("id" )) > entry .getValue ().getKey ()) {
451445 System .out .println (Ansi .ansi ().fg (Ansi .Color .YELLOW ).a (entry .getValue ().getValue ()).reset ().a (" | " ).fg (Ansi .Color .MAGENTA ).a (entry .getKey ()));
452446 updatables .put (entry .getKey (), entry .getValue ().getValue ());
453447 }
454448 } catch (Exception e ) {
449+ System .out .println (Ansi .ansi ().fg (Ansi .Color .RED ).a ("Having trouble with mod " + entry .getKey ()));
455450 e .printStackTrace ();
456451 }
457452 }
@@ -463,7 +458,7 @@ private static void update(String[] args) {
463458 String cmd = "curseforge profile add <profile> " + mods .keySet ().stream ().map (String ::valueOf ).collect (Collectors .joining (" " ));
464459 pw .println (cmd );
465460 pw .close ();
466- System .out .println (Ansi .ansi ().fg (Ansi .Color .GREEN ).a ("Exported mods with update available to search .txt" ));
461+ System .out .println (Ansi .ansi ().fg (Ansi .Color .GREEN ).a ("Exported mods with update available to mod_updates .txt" ));
467462 } catch (Exception e ) {
468463 e .printStackTrace ();
469464 }
@@ -476,10 +471,7 @@ private static void update(String[] args) {
476471 JSONObject json = (JSONObject ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + id );
477472 if (json == null || ((long ) ((JSONObject ) json .get ("categorySection" )).get ("gameCategoryId" )) != 6 ) throw new Exception ("The ID " +id +" does not represent a mod." );
478473 JSONArray files = (JSONArray ) Utils .readJsonFromUrl (Constants .CURSEFORGE_API + id + "/files" );
479- List f = (List ) files .stream ().filter (o -> {
480- JSONArray versions = (JSONArray ) ((JSONObject ) o ).get ("gameVersion" );
481- return versions .get (0 ).equals (config .get ("mcVer" )) && ((String ) versions .get (1 )).equalsIgnoreCase ((String ) config .get ("launcher" ));
482- }).collect (Collectors .toList ());
474+ List f = (List ) files .stream ().filter (o -> Utils .checkVersion ((JSONArray ) ((JSONObject ) o ).get ("gameVersion" ), config )).collect (Collectors .toList ());
483475 f .sort ((a , b ) -> (int ) ((long ) ((JSONObject ) b ).get ("id" ) - (long ) ((JSONObject ) a ).get ("id" )));
484476 if (f .size () < 1 ) throw new Exception ("No available file of " + id + " found for this profile." );
485477 JSONObject bestFile = (JSONObject ) f .get (0 );
0 commit comments