File tree Expand file tree Collapse file tree 3 files changed +37
-3
lines changed
src/main/java/io/github/axolotlclient/installer Expand file tree Collapse file tree 3 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 4141
4242import io .github .axolotlclient .installer .modrinth .api .ProjectFile ;
4343import io .github .axolotlclient .installer .modrinth .api .ProjectVersion ;
44+ import io .github .axolotlclient .installer .modrinth .api .ReleaseChannel ;
4445import io .github .axolotlclient .installer .modrinth .pack .MrPack ;
4546import io .github .axolotlclient .installer .util .MinecraftVersionComparator ;
4647import io .github .axolotlclient .installer .util .Util ;
@@ -81,8 +82,12 @@ private static String getIcon() {
8182 public void load () throws IOException {
8283 // create a mapping of game version to latest mod version
8384 ProjectVersion .getFeatured (MR_SLUG ).forEach ((version ) -> {
84- for (String game : version .getGameVersions ())
85- this .modVerFromGameVer .put (game , version );
85+ if (version .getVersionType () != ReleaseChannel .RELEASE )
86+ return ;
87+
88+ for (String gameVersion : version .getGameVersions ())
89+ if (!this .modVerFromGameVer .containsKey (gameVersion ))
90+ this .modVerFromGameVer .put (gameVersion , version );
8691 });
8792 // collect a sorted list of game versions
8893 availableGameVers = modVerFromGameVer .keySet ().stream ().sorted (MinecraftVersionComparator .INSTANCE .reversed ())
Original file line number Diff line number Diff line change 3636
3737public class ProjectVersion {
3838
39- private static final String URL_FORMAT = "https://api.modrinth.com/v2/project/%s/version?featured=true " ;
39+ private static final String URL_FORMAT = "https://api.modrinth.com/v2/project/%s/version" ;
4040
4141 private final List <String > gameVersions ;
4242 private final List <ProjectFile > files ;
43+ private final ReleaseChannel versionType ;
4344
4445 public static List <ProjectVersion > getFeatured (String slug ) throws IOException {
4546 URL url = new URL (String .format (URL_FORMAT , slug ));
@@ -54,6 +55,7 @@ public ProjectVersion(JsonObject obj) {
5455 .collect (Collectors .toList ());
5556 this .files = obj .get ("files" ).asArray ().stream ().map (JsonValue ::asObject ).map (ProjectFile ::new )
5657 .collect (Collectors .toList ());
58+ this .versionType = ReleaseChannel .parse (obj .get ("version_type" ).getStringValue ());
5759 }
5860
5961 public List <String > getGameVersions () {
@@ -63,4 +65,8 @@ public List<String> getGameVersions() {
6365 public List <ProjectFile > getFiles () {
6466 return files ;
6567 }
68+
69+ public ReleaseChannel getVersionType () {
70+ return versionType ;
71+ }
6672}
Original file line number Diff line number Diff line change 1+ package io .github .axolotlclient .installer .modrinth .api ;
2+
3+ import java .util .Locale ;
4+
5+ public enum ReleaseChannel {
6+ RELEASE ,
7+ BETA ,
8+ ALPHA ;
9+
10+ public static ReleaseChannel parse (String value ) {
11+ switch (value ) {
12+ case "release" :
13+ return RELEASE ;
14+ case "beta" :
15+ return BETA ;
16+ case "alpha" :
17+ return ALPHA ;
18+ }
19+
20+ throw new IllegalArgumentException (value );
21+ }
22+
23+ }
You can’t perform that action at this time.
0 commit comments