1414import net .minecraft .client .MinecraftClient ;
1515import net .minecraft .client .toast .SystemToast ;
1616import net .minecraft .text .Text ;
17-
1817import net .minecraft .util .Util ;
1918import org .jetbrains .annotations .Nullable ;
2019import org .slf4j .Logger ;
@@ -52,7 +51,12 @@ private static void checkForUpdates0() {
5251 try (var executor = Executors .newThreadPerTaskExecutor (new UpdateCheckerThreadFactory ())) {
5352 List <Mod > withoutUpdateChecker = new ArrayList <>();
5453
55- ModMenu .MODS .values ().stream ().filter (UpdateCheckerUtil ::allowsUpdateChecks ).forEach (mod -> {
54+ List <Mod > updatableMods = ModMenu .MODS .values ()
55+ .stream ()
56+ .filter (UpdateCheckerUtil ::allowsUpdateChecks )
57+ .toList ();
58+
59+ for (Mod mod : updatableMods ) {
5660 UpdateChecker updateChecker = mod .getUpdateChecker ();
5761
5862 if (updateChecker == null ) {
@@ -72,7 +76,7 @@ private static void checkForUpdates0() {
7276 LOGGER .info ("Update available for '{}@{}'" , mod .getId (), mod .getVersion ());
7377 });
7478 }
75- });
79+ }
7680
7781 if (modrinthApiV2Deprecated ) {
7882 return ;
@@ -120,7 +124,10 @@ private static void checkForUpdates0() {
120124
121125 for (var mod : modHashes .get (hash )) {
122126 mod .setUpdateInfo (data .asUpdateInfo ());
123- LOGGER .info ("Update available for '{}@{}', (-> {})" , mod .getId (), mod .getVersion (), data .versionNumber );
127+ LOGGER .info ("Update available for '{}@{}', (-> {})" ,
128+ mod .getId (),
129+ mod .getVersion (),
130+ data .versionNumber );
124131 }
125132 }
126133 }
@@ -143,17 +150,18 @@ private static Map<String, Set<Mod>> getModHashes(Collection<Mod> mods) {
143150 } catch (IOException e ) {
144151 LOGGER .error ("Error getting mod hash for mod {}: " , modId , e );
145152 }
146- };
153+ }
154+ ;
147155
148156 return results ;
149157 }
150158
151159 public static void triggerV2DeprecatedToast () {
152160 if (modrinthApiV2Deprecated && ModMenuConfig .UPDATE_CHECKER .getValue ()) {
153161 MinecraftClient .getInstance ().getToastManager ().add (new SystemToast (
154- SystemToast .Type .PERIODIC_NOTIFICATION ,
155- Text .translatable ("modmenu.modrinth.v2_deprecated.title" ),
156- Text .translatable ("modmenu.modrinth.v2_deprecated.description" )
162+ SystemToast .Type .PERIODIC_NOTIFICATION ,
163+ Text .translatable ("modmenu.modrinth.v2_deprecated.title" ),
164+ Text .translatable ("modmenu.modrinth.v2_deprecated.description" )
157165 ));
158166 }
159167 }
@@ -233,7 +241,10 @@ private static UpdateChannel getUpdateChannel(String versionType) {
233241 updateChannels = List .of (UpdateChannel .ALPHA , UpdateChannel .BETA , UpdateChannel .RELEASE );
234242 }
235243
236- String body = ModMenu .GSON_MINIFIED .toJson (new LatestVersionsFromHashesBody (modHashes , loaders , mcVer , updateChannels ));
244+ String body = ModMenu .GSON_MINIFIED .toJson (new LatestVersionsFromHashesBody (modHashes ,
245+ loaders ,
246+ mcVer ,
247+ updateChannels ));
237248
238249 LOGGER .debug ("Body: {}" , body );
239250 var latestVersionsRequest = HttpRequest .newBuilder ()
@@ -275,9 +286,15 @@ private static UpdateChannel getUpdateChannel(String versionType) {
275286 }
276287
277288 var updateChannel = UpdateCheckerUtil .getUpdateChannel (versionType );
278- var versionHash = primaryFile .get ().getAsJsonObject ().get ("hashes" ).getAsJsonObject ().get ("sha512" ).getAsString ();
279-
280- results .put (lookupHash , new VersionUpdate (projectId , versionId , versionNumber , date , updateChannel , versionHash ));
289+ var versionHash = primaryFile .get ()
290+ .getAsJsonObject ()
291+ .get ("hashes" )
292+ .getAsJsonObject ()
293+ .get ("sha512" )
294+ .getAsString ();
295+
296+ results .put (lookupHash ,
297+ new VersionUpdate (projectId , versionId , versionNumber , date , updateChannel , versionHash ));
281298 });
282299
283300 return results ;
@@ -311,7 +328,10 @@ public static class LatestVersionsFromHashesBody {
311328 @ SerializedName ("version_types" )
312329 public Collection <String > versionTypes ;
313330
314- public LatestVersionsFromHashesBody (Collection <String > hashes , Collection <String > loaders , String mcVersion , Collection <UpdateChannel > updateChannels ) {
331+ public LatestVersionsFromHashesBody (Collection <String > hashes ,
332+ Collection <String > loaders ,
333+ String mcVersion ,
334+ Collection <UpdateChannel > updateChannels ) {
315335 this .hashes = hashes ;
316336 this .loaders = loaders ;
317337 this .gameVersions = Set .of (mcVersion );
0 commit comments