Skip to content

Commit a542fef

Browse files
committed
Filter by release instead of featured versions
Modrinth removed featured versions - the flag now seems to only be on old files.
1 parent a51f803 commit a542fef

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

src/main/java/io/github/axolotlclient/installer/Installer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import io.github.axolotlclient.installer.modrinth.api.ProjectFile;
4343
import io.github.axolotlclient.installer.modrinth.api.ProjectVersion;
44+
import io.github.axolotlclient.installer.modrinth.api.ReleaseChannel;
4445
import io.github.axolotlclient.installer.modrinth.pack.MrPack;
4546
import io.github.axolotlclient.installer.util.MinecraftVersionComparator;
4647
import 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())

src/main/java/io/github/axolotlclient/installer/modrinth/api/ProjectVersion.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@
3636

3737
public 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
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
}

0 commit comments

Comments
 (0)