diff --git a/src/main/java/com/terraformersmc/modmenu/api/UpdateChannel.java b/src/main/java/com/terraformersmc/modmenu/api/UpdateChannel.java index fe408250..4c51835c 100644 --- a/src/main/java/com/terraformersmc/modmenu/api/UpdateChannel.java +++ b/src/main/java/com/terraformersmc/modmenu/api/UpdateChannel.java @@ -13,7 +13,7 @@ public enum UpdateChannel { /** * @return the user's preferred update channel. */ - public UpdateChannel getUserPreference() { + public static UpdateChannel getUserPreference() { return ModMenuConfig.UPDATE_CHANNEL.getValue(); } } diff --git a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java index fc39d28a..ce4ef7ce 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java +++ b/src/main/java/com/terraformersmc/modmenu/util/UpdateCheckerUtil.java @@ -86,7 +86,20 @@ public static void checkForModrinthUpdates() { .get().getMetadata().getVersion().getFriendlyString().split("\\+", 1); // Strip build metadata for privacy final var modMenuVersion = splitVersion.length > 1 ? splitVersion[1] : splitVersion[0]; final var userAgent = "%s/%s (%s/%s%s)".formatted(ModMenu.GITHUB_REF, modMenuVersion, mcVer, primaryLoader, environment); - String body = ModMenu.GSON_MINIFIED.toJson(new LatestVersionsFromHashesBody(modHashes.keySet(), loaders, mcVer)); + + List updateChannels; + UpdateChannel preferredChannel = UpdateChannel.getUserPreference(); + + if (preferredChannel == UpdateChannel.RELEASE) { + updateChannels = List.of(UpdateChannel.RELEASE); + } else if (preferredChannel == UpdateChannel.BETA) { + updateChannels = List.of(UpdateChannel.BETA, UpdateChannel.RELEASE); + } else { + updateChannels = List.of(UpdateChannel.ALPHA, UpdateChannel.BETA, UpdateChannel.RELEASE); + } + + String body = ModMenu.GSON_MINIFIED.toJson(new LatestVersionsFromHashesBody(modHashes.keySet(), loaders, mcVer, updateChannels)); + LOGGER.debug("User agent: " + userAgent); LOGGER.debug("Body: " + body); var latestVersionsRequest = HttpRequest.newBuilder() @@ -161,11 +174,14 @@ public static class LatestVersionsFromHashesBody { public Collection loaders; @SerializedName("game_versions") public Collection gameVersions; + @SerializedName("version_types") + public Collection versionTypes; - public LatestVersionsFromHashesBody(Collection hashes, Collection loaders, String mcVersion) { + public LatestVersionsFromHashesBody(Collection hashes, Collection loaders, String mcVersion, Collection updateChannels) { this.hashes = hashes; this.loaders = loaders; this.gameVersions = Set.of(mcVersion); + this.versionTypes = updateChannels.stream().map(value -> value.toString().toLowerCase()).toList(); } } }