Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class GitCraftQuirks {
/// Mapping quirks
Expand Down Expand Up @@ -55,4 +57,8 @@ public class GitCraftQuirks {

// There are no releases for these parchment versions (yet)
public static List<String> parchmentMissingVersions = List.of("1.18", "1.19", "1.19.1", "1.20", "1.20.5", "1.21.2");

// Special cases for Omniarchive manifest
public static List<String> omniarchiveSpecialSnapshots = List.of("1.0.0-tominecon", "13w02a-whitetexturefix", "13w04a-whitelinefix", "1.5-pre-whitelinefix", "13w12~-1439");
public static List<String> omniarchiveLinearSpecials = Stream.concat(Stream.of("c0.0.11a-launcher", "c0.0.13a-launcher", "b1.6-tb3"), omniarchiveSpecialSnapshots.stream()).collect(Collectors.toList());
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.github.winplay02.gitcraft.manifest.omniarchive;

import java.util.List;
import java.util.regex.Pattern;

import com.github.winplay02.gitcraft.GitCraftQuirks;
import com.github.winplay02.gitcraft.manifest.ManifestSource;
import com.github.winplay02.gitcraft.manifest.vanilla.MojangLauncherMetadataProvider;
import com.github.winplay02.gitcraft.types.OrderedVersion;

public class OmniarchiveMetadataProvider extends MojangLauncherMetadataProvider {

Expand All @@ -29,6 +32,72 @@ public String getInternalName() {
@Override
public List<String> getParentVersionIds(String versionId) {
switch (versionId) {
// Combat
case "combat1" -> {
return List.of("1.14.3-pre4");
}
case "combat2" -> {
return List.of("combat1", "1.14.4");
}
case "combat3" -> {
return List.of("combat2");
}
case "combat4" -> {
return List.of("combat3", "1.15-pre3");
}
case "combat5" -> {
return List.of("combat4", "1.15.2-pre2");
}
case "combat6" -> {
return List.of("combat5", "1.16.2-pre3");
}
case "combat7" -> {
return List.of("combat6", "1.16.2");
}
case "combat7b" -> {
return List.of("combat7");
}
case "combat7c" -> {
return List.of("combat7b");
}
case "combat8" -> {
return List.of("combat7c");
}
case "combat8b" -> {
return List.of("combat8");
}
case "combat8c" -> {
return List.of("combat8b");
}
// Experimental 1.18
case "1.18-exp1" -> {
return List.of("1.17.1-pre1");
}
case "1.18-exp2" -> {
return List.of("1.18-exp1");
}
case "1.18-exp3" -> {
return List.of("1.18-exp2");
}
case "1.18-exp4" -> {
return List.of("1.18-exp3");
}
case "1.18-exp5" -> {
return List.of("1.18-exp4");
}
case "1.18-exp6" -> {
return List.of("1.18-exp5");
}
case "1.18-exp7" -> {
return List.of("1.18-exp6");
}
case "21w37a" -> {
return List.of("1.17.1", "1.18-exp7");
}
// Experimental 1.19
case "1.19-exp1" -> {
return List.of("1.18.1");
}
// Unobfuscated
case "25w45a-unobf" -> {
return List.of("25w44a");
Expand Down Expand Up @@ -67,11 +136,83 @@ public List<String> getParentVersionIds(String versionId) {
return List.of("1.21.11-unobf", "1.21.11");
}
// April
case "2.0-preview" -> {
return List.of("1.5.1");
}
case "2.0-blue" -> {
return List.of("1.5.1");
}
case "2.0-purple" -> {
return List.of("1.5.1");
}
case "2.0-red" -> {
return List.of("1.5.1");
}
case "3D Shareware v1.34" -> {
return List.of("19w13b+1653");
return List.of("19w13b-1653");
}
case "23w13a_or_b-0722" -> {
return List.of("23w13a");
}
case "23w13a_or_b-1249" -> {
return List.of("23w13a_or_b-0722");
}
case "24w14potato-0838" -> {
return List.of("24w12a");
}
case "24w14potato-1104" -> {
return List.of("24w14potato-0838");
}
// Beta
case "b1.3-demo" -> {
return List.of("b1.3_01");
}
case "b1.2_02-dev" -> {
return List.of("b1.2_02");
}
// Classic
case "c0.30-c-1900-renew" -> {
return List.of("c0.30-c-1900");
}
}

String launcher_duplicate = this.getLauncherVersionDuplicate(versionId);
if (launcher_duplicate != null) {
return List.of(launcher_duplicate);
}

return super.getParentVersionIds(versionId);
}

private static final Pattern OMNI_NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z](-\\d+)?$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot-)(\\d+)?(-\\d+)?)?$)");

@Override
protected Pattern getNormalSnapshotPattern() {
return OMNI_NORMAL_SNAPSHOT_PATTERN;
}

private static final String LAUNCHER_SUFFIX = "-launcher";

private String getLauncherVersionDuplicate(String versionId) {
if (versionId.endsWith(LAUNCHER_SUFFIX)) {
String potential_duplicate = versionId.substring(0, versionId.length() - LAUNCHER_SUFFIX.length());
if (this.getVersionsAssumeLoaded().containsKey(potential_duplicate)) {
return potential_duplicate;
}
}
return null;
}

@Override
public boolean shouldExcludeFromMainBranch(OrderedVersion mcVersion) {
return super.shouldExcludeFromMainBranch(mcVersion)
// Exclude all april fools snapshots
|| mcVersion.isAprilFools()
// Exclude special versions such as combat experiments and b1.3-demo
|| (mcVersion.isSpecial()
// Allow special versions which do not branch out
&& !GitCraftQuirks.omniarchiveLinearSpecials.contains(mcVersion.launcherFriendlyVersionName()))
// Exclude duplicate versions from launcher
|| (this.getLauncherVersionDuplicate(mcVersion.launcherFriendlyVersionName()) != null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ protected boolean isExistingVersionMetadataValid(MojangLauncherManifest.VersionE

// Version Override
private static final Map<String, String> minecraftVersionSemVerOverride = Map.of(
// Fixes for Omniarchive manifest
// present in Omniarchive manifest and fabric-loader does not parse it correctly
"2.0-preview", "2.0-preview",
// More fixes for Omniarchive manifest
"1.21.11-pre1-unobf", "1.21.11-beta.1+unobfuscated",
"1.21.11-pre2-unobf", "1.21.11-beta.2+unobfuscated",
"1.21.11-pre3-unobf", "1.21.11-beta.3+unobfuscated",
Expand Down Expand Up @@ -464,11 +466,15 @@ protected List<String> getParentVersionIds(String versionId) {

private static final Pattern NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z]$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot-)\\d+|_[a-z_\\-]+snapshot-\\d+| Pre-Release \\d+)?$)");

protected Pattern getNormalSnapshotPattern() {
return NORMAL_SNAPSHOT_PATTERN;
}

@Override
public boolean shouldExcludeFromMainBranch(OrderedVersion mcVersion) {
return super.shouldExcludeFromMainBranch(mcVersion)
// filter out april fools snapshots and experimental versions,
// which often have typical ids that do not match normal snapshots
|| (mcVersion.isSnapshotOrPending() && !NORMAL_SNAPSHOT_PATTERN.matcher(mcVersion.launcherFriendlyVersionName()).matches());
|| (mcVersion.isSnapshotOrPending() && !this.getNormalSnapshotPattern().matcher(mcVersion.launcherFriendlyVersionName()).matches());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,40 @@ public int javaVersion() {

public boolean isSnapshot() {
return Objects.equals(this.versionInfo().type(), "snapshot")
// special case required because the manifest for experimental unobfuscated versions
// does not specify their snapshot status and always uses 'unobfuscated' as version type
|| (this.isUnobfuscated() && UNOBFUSCATED_SNAPSHOT_PATTERN.matcher(this.versionInfo().id()).matches());
// Special case required because the manifest for experimental unobfuscated versions
// does not specify their snapshot status and always uses 'unobfuscated' as version type
|| (this.isUnobfuscated() && UNOBFUSCATED_SNAPSHOT_PATTERN.matcher(this.versionInfo().id()).matches())
// Another special case for snapshots from Omniarchive manifest which are marked as "special"
|| (this.isSpecial() && GitCraftQuirks.omniarchiveSpecialSnapshots.contains(this.versionInfo().id()))
// Mark april fools versions from Omniarchive as snapshots
|| this.isAprilFools();
}

public boolean isPending() {
return Objects.equals(this.versionInfo().type(), "pending");
}

// Mojang and Skyrising
/**
* This method is <i>specifically</i> for checking if this is an <i>experimental</i> <c>"unobfuscated"</c> version.
* To determine whether this version has no obfuscation use {@link OrderedVersion#isNotObfuscated()}.
*/
public boolean isUnobfuscated() {
return Objects.equals(this.versionInfo().type(), "unobfuscated")
// special case for omniarchive manifest
|| (this.isSpecial() && this.versionInfo().id().endsWith("-unobf"));
// special case for omniarchive manifest
|| (this.isSpecial() && this.versionInfo().id().endsWith("-unobf"));
}

// Can be found in Omniarchive manifest
// Omniarchive
public boolean isSpecial() {
return Objects.equals(this.versionInfo().type(), "special");
}

// Omniarchive
public boolean isAprilFools() {
return Objects.equals(this.versionInfo().type(), "april-fools");
}

public boolean isSnapshotOrPending() {
return this.isSnapshot() || this.isPending();
}
Expand Down