Skip to content

Commit c9b1cfe

Browse files
authored
[release/3.13] 修复 CurseForge 源中内容不显示 Minecraft 26.x 版本的问题 (#6003)
#5994
1 parent 82460eb commit c9b1cfe

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.jackhuang.hmcl.util.Immutable;
2525
import org.jackhuang.hmcl.util.Lang;
2626
import org.jackhuang.hmcl.util.Pair;
27+
import org.jackhuang.hmcl.util.versioning.GameVersionNumber;
2728
import org.jetbrains.annotations.Nullable;
2829

2930
import java.io.IOException;
@@ -585,7 +586,7 @@ public RemoteMod.Version toVersion() {
585586
}
586587
return RemoteMod.Dependency.ofGeneral(RELATION_TYPE.get(dependency.getRelationType()), CurseForgeRemoteModRepository.MODS, Integer.toString(dependency.getModId()));
587588
}).distinct().filter(Objects::nonNull).collect(Collectors.toList()),
588-
gameVersions.stream().filter(ver -> ver.startsWith("1.") || ver.contains("w")).collect(Collectors.toList()),
589+
gameVersions.stream().filter(GameVersionNumber::isKnown).toList(),
589590
gameVersions.stream().flatMap(version -> {
590591
if ("fabric".equalsIgnoreCase(version)) return Stream.of(ModLoaderType.FABRIC);
591592
else if ("forge".equalsIgnoreCase(version)) return Stream.of(ModLoaderType.FORGE);

HMCLCore/src/main/java/org/jackhuang/hmcl/util/versioning/GameVersionNumber.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ public static VersionRange<GameVersionNumber> atMost(String maximum) {
9595
return VersionRange.atMost(asGameVersion(maximum));
9696
}
9797

98+
/// Determines whether the given version string corresponds to a known Minecraft version.
99+
///
100+
/// If the version string cannot be parsed as any known version type (release, snapshot, pre-release, etc.)
101+
/// and is not a known April Fools snapshot, it is considered an unknown version.
102+
///
103+
/// @param version the version string to check, e.g. `"1.21.4"`, `"25w14craftmine"`, etc.
104+
/// @return {@code true} if the version string corresponds to a known Minecraft version, {@code false} otherwise
105+
/// @see #asGameVersion(String)
106+
public static boolean isKnown(String version) {
107+
return !(asGameVersion(version) instanceof Special special && special.prev == null);
108+
}
109+
98110
final String value;
99111
final String normalized;
100112

@@ -151,7 +163,7 @@ public boolean isAtLeast(@NotNull String releaseVersion, @NotNull String snapsho
151163
///
152164
/// ```java
153165
/// GameVersionNumber.asVersion("...").isAtLeast("1.13", "17w43a");
154-
///```
166+
/// ```
155167
///
156168
/// @param strictReleaseVersion When `strictReleaseVersion` is `false`, `releaseVersion` is considered less than
157169
/// its corresponding pre/rc versions.

0 commit comments

Comments
 (0)