[release/3.12] Add Minecraft 26.1 snapshot/pre/rc versions (#5848)

https://github.com/HMCL-dev/HMCL/pull/5833
This commit is contained in:
Glavo authored and GitHub committed 2026-03-24 21:37:20 +08:00
1 parent ae4c152a8b
commit 4921804283
3 files changed
+50 -11

No files matched your search

@@ -268,18 +268,26 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
}
public static final class Release extends GameVersionNumber {
private static final int MINIMUM_YEAR_MAJOR_VERSION = 25;
private static final int MINIMUM_YEAR_MAJOR_VERSION = 26;
public enum ReleaseType {
UNKNOWN(""),
SNAPSHOT("-snapshot-"),
PRE_RELEASE("-pre"),
RELEASE_CANDIDATE("-rc"),
PRE_RELEASE("-pre", "-pre-"),
RELEASE_CANDIDATE("-rc", "-rc-"),
GA("");
private final String infix;
private final String legacyInfix;
private final String newInfix;
ReleaseType(String infix) {
this.infix = infix;
this.legacyInfix = infix;
this.newInfix = infix;
}
ReleaseType(String legacyInfix, String newInfix) {
this.legacyInfix = legacyInfix;
this.newInfix = newInfix;
}
}
@@ -317,6 +325,8 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
String suffix = matcher.group("suffix");
boolean isLegacyRelease = major == 1;
ReleaseType releaseType;
VersionNumber eaVersion;
Additional additional = Additional.NONE;
@@ -342,10 +352,15 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
releaseType = ReleaseType.SNAPSHOT;
eaVersion = VersionNumber.asVersion(suffix.substring(" Snapshot ".length()));
} else if (suffix.startsWith("-pre-")) {
needNormalize = true;
if (isLegacyRelease) {
needNormalize = true;
}
releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring("-pre-".length()));
} else if (suffix.startsWith("-pre")) {
if (!isLegacyRelease) {
needNormalize = true;
}
releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring("-pre".length()));
} else if (suffix.startsWith(" Pre-Release ")) {
@@ -358,10 +373,15 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring(" Pre-release ".length()));
} else if (suffix.startsWith("-rc-")) {
needNormalize = true;
if (isLegacyRelease) {
needNormalize = true;
}
releaseType = ReleaseType.RELEASE_CANDIDATE;
eaVersion = VersionNumber.asVersion(suffix.substring("-rc-".length()));
} else if (suffix.startsWith("-rc")) {
if (!isLegacyRelease) {
needNormalize = true;
}
releaseType = ReleaseType.RELEASE_CANDIDATE;
eaVersion = VersionNumber.asVersion(suffix.substring("-rc".length()));
} else if (suffix.startsWith(" Release Candidate ")) {
@@ -377,7 +397,7 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
StringBuilder builder = new StringBuilder(value.length());
builder.append(matcher.group("prefix"));
if (releaseType != ReleaseType.GA) {
builder.append(releaseType.infix);
builder.append(isLegacyRelease ? releaseType.legacyInfix : releaseType.newInfix);
builder.append(eaVersion);
}
builder.append(additional.suffix);
@@ -895,3 +895,20 @@
1.21.11-rc3_unobfuscated
1.21.11
1.21.11_unobfuscated
26.1-snapshot-1
26.1-snapshot-2
26.1-snapshot-3
26.1-snapshot-4
26.1-snapshot-5
26.1-snapshot-6
26.1-snapshot-7
26.1-snapshot-8
26.1-snapshot-9
26.1-snapshot-10
26.1-snapshot-11
26.1-pre-1
26.1-pre-2
26.1-pre-3
26.1-rc-1
26.1-rc-2
26.1
@@ -432,14 +432,13 @@ public final class GameVersionNumberTest {
assertNormalized(version, version);
}
assertNormalized("26.1-snapshot-1", "26.1 Snapshot 1");
assertNormalized("1.21.11-pre3", "1.21.11-pre-3");
assertNormalized("1.21.11-pre3", "1.21.11 Pre-Release 3");
assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11 Pre-Release 3 Unobfuscated");
assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11-pre3 Unobfuscated");
assertNormalized("26.1-pre1", "26.1-pre-1");
assertNormalized("1.21.11-rc1", "1.21.11-rc-1");
assertNormalized("1.21.11-rc1", "1.21.11 Release Candidate 1");
assertNormalized("1.21.11-rc1_unobfuscated", "1.21.11 Release Candidate 1 Unobfuscated");
assertNormalized("26.1-rc1", "26.1-rc-1");
assertNormalized("1.14_combat-212796", "1.14.3 - Combat Test");
assertNormalized("1.14_combat-0", "Combat Test 2");
assertNormalized("1.14_combat-3", "Combat Test 3");
@@ -463,6 +462,9 @@ public final class GameVersionNumberTest {
assertNormalized("1.19_deep_dark_experimental_snapshot-1", "Deep Dark Experimental Snapshot 1");
assertNormalized("20w14infinite", "20w14~");
assertNormalized("22w13oneBlockAtATime", "22w13oneblockatatime");
assertNormalized("26.1-snapshot-1", "26.1 Snapshot 1");
assertNormalized("26.1-rc-1", "26.1-rc1");
assertNormalized("26.1-pre-1", "26.1-pre1");
}
@Test