* Fix #2854: 修复 LibraryAnalyzer.analyze 无法获得游戏版本的问题 * delete debug code * update
This commit is contained in:
@@ -106,7 +106,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
Version original = repository.getVersion(version.getId());
|
||||
Version resolved = original.resolvePreservingPatches(repository);
|
||||
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(resolved);
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(resolved, repository.getGameVersion(resolved).orElse(null));
|
||||
for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) {
|
||||
if (!analyzer.has(type))
|
||||
continue;
|
||||
@@ -218,8 +218,9 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
if (version.isResolved())
|
||||
throw new IllegalArgumentException("removeLibraryWithoutSavingAsync requires non-resolved version");
|
||||
Version independentVersion = version.resolvePreservingPatches(repository);
|
||||
String gameVersion = repository.getGameVersion(independentVersion).orElse(null);
|
||||
|
||||
return Task.supplyAsync(() -> LibraryAnalyzer.analyze(independentVersion).removeLibrary(libraryId).build());
|
||||
return Task.supplyAsync(() -> LibraryAnalyzer.analyze(independentVersion, gameVersion).removeLibrary(libraryId).build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -130,12 +130,16 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
|
||||
return version;
|
||||
}
|
||||
|
||||
public static LibraryAnalyzer analyze(Version version) {
|
||||
public static LibraryAnalyzer analyze(Version version, String gameVersion) {
|
||||
if (version.getInheritsFrom() != null)
|
||||
throw new IllegalArgumentException("LibraryAnalyzer can only analyze independent game version");
|
||||
|
||||
Map<String, Pair<Library, String>> libraries = new HashMap<>();
|
||||
|
||||
if (gameVersion != null) {
|
||||
libraries.put(LibraryType.MINECRAFT.getPatchId(), pair(null, gameVersion));
|
||||
}
|
||||
|
||||
List<Library> rawLibraries = version.resolve(null).getLibraries();
|
||||
for (Library library : rawLibraries) {
|
||||
for (LibraryType type : LibraryType.values()) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class MaintainTask extends Task<Version> {
|
||||
String mainClass = version.resolve(null).getMainClass();
|
||||
|
||||
if (mainClass != null && mainClass.equals(LibraryAnalyzer.LAUNCH_WRAPPER_MAIN)) {
|
||||
version = maintainOptiFineLibrary(repository, maintainGameWithLaunchWrapper(unique(version), true), false);
|
||||
version = maintainOptiFineLibrary(repository, maintainGameWithLaunchWrapper(repository, unique(version), true), false);
|
||||
} else if (mainClass != null && mainClass.equals(LibraryAnalyzer.MOD_LAUNCHER_MAIN)) {
|
||||
// Forge 1.13 and OptiFine
|
||||
version = maintainOptiFineLibrary(repository, maintainGameWithCpwModLauncher(repository, unique(version)), true);
|
||||
@@ -97,8 +97,8 @@ public class MaintainTask extends Task<Version> {
|
||||
return newVersion.setPatches(version.getPatches()).markAsUnresolved();
|
||||
}
|
||||
|
||||
private static Version maintainGameWithLaunchWrapper(Version version, boolean reorderTweakClass) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version);
|
||||
private static Version maintainGameWithLaunchWrapper(GameRepository repository, Version version, boolean reorderTweakClass) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||
String mainClass = null;
|
||||
|
||||
@@ -147,7 +147,7 @@ public class MaintainTask extends Task<Version> {
|
||||
}
|
||||
|
||||
private static Version maintainGameWithCpwModLauncher(GameRepository repository, Version version) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version);
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||
|
||||
if (!libraryAnalyzer.has(FORGE)) return version;
|
||||
@@ -205,7 +205,7 @@ public class MaintainTask extends Task<Version> {
|
||||
|
||||
// Fix wrong configurations when launching 1.17+ with Forge.
|
||||
private static Version maintainGameWithCpwBoostrapLauncher(GameRepository repository, Version version) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version);
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||
|
||||
if (!libraryAnalyzer.has(FORGE) && !libraryAnalyzer.has(NEO_FORGE)) return version;
|
||||
@@ -247,7 +247,7 @@ public class MaintainTask extends Task<Version> {
|
||||
}
|
||||
|
||||
private static Version maintainOptiFineLibrary(GameRepository repository, Version version, boolean remove) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version);
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
||||
List<Library> libraries = new ArrayList<>(version.getLibraries());
|
||||
|
||||
if (libraryAnalyzer.has(OPTIFINE)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class GameVerificationFixTask extends Task<Void> {
|
||||
@Override
|
||||
public void execute() throws IOException {
|
||||
File jar = dependencyManager.getGameRepository().getVersionJar(version);
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version);
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version, gameVersion);
|
||||
|
||||
if (jar.exists() && GameVersionNumber.compare(gameVersion, "1.6") < 0 && analyzer.has(LibraryAnalyzer.LibraryType.FORGE)) {
|
||||
try (FileSystem fs = CompressingUtils.createWritableZipFileSystem(jar.toPath(), StandardCharsets.UTF_8)) {
|
||||
|
||||
@@ -226,7 +226,7 @@ public enum JavaVersionConstraint {
|
||||
public static VersionRanges findSuitableJavaVersionRange(GameVersionNumber gameVersion, Version version) {
|
||||
VersionRange<VersionNumber> mandatoryJavaRange = VersionRange.all();
|
||||
VersionRange<VersionNumber> suggestedJavaRange = VersionRange.all();
|
||||
LibraryAnalyzer analyzer = version != null ? LibraryAnalyzer.analyze(version) : null;
|
||||
LibraryAnalyzer analyzer = version != null ? LibraryAnalyzer.analyze(version, gameVersion != null ? gameVersion.toString() : null) : null;
|
||||
for (JavaVersionConstraint java : ALL) {
|
||||
if (java.appliesToVersion(gameVersion, version, null, analyzer)) {
|
||||
VersionRange<VersionNumber> javaVersionRange = java.getJavaVersionRange(version);
|
||||
|
||||
@@ -505,7 +505,7 @@ public class DefaultLauncher extends Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version);
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
||||
if (analyzer.has(LibraryAnalyzer.LibraryType.FORGE)) {
|
||||
env.put("INST_FORGE", "1");
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public class McbbsModpackExportTask extends Task<Void> {
|
||||
}
|
||||
});
|
||||
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(version));
|
||||
String gameVersion = repository.getGameVersion(version)
|
||||
.orElseThrow(() -> new IOException("Cannot parse the version of " + version));
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(version), gameVersion);
|
||||
|
||||
// Mcbbs manifest
|
||||
List<McbbsModpackManifest.Addon> addons = new ArrayList<>();
|
||||
|
||||
@@ -70,9 +70,9 @@ public class MultiMCModpackExportTask extends Task<Void> {
|
||||
try (Zipper zip = new Zipper(output.toPath())) {
|
||||
zip.putDirectory(repository.getRunDirectory(versionId).toPath(), ".minecraft", path -> Modpack.acceptFile(path, blackList, whitelist));
|
||||
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(versionId));
|
||||
String gameVersion = repository.getGameVersion(versionId)
|
||||
.orElseThrow(() -> new IOException("Cannot parse the version of " + versionId));
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(versionId), gameVersion);
|
||||
List<MultiMCManifest.MultiMCManifestComponent> components = new ArrayList<>();
|
||||
components.add(new MultiMCManifest.MultiMCManifestComponent(true, false, "net.minecraft", gameVersion));
|
||||
analyzer.getVersion(FORGE).ifPresent(forgeVersion ->
|
||||
|
||||
@@ -78,9 +78,9 @@ public class ServerModpackExportTask extends Task<Void> {
|
||||
}
|
||||
});
|
||||
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(versionId));
|
||||
String gameVersion = repository.getGameVersion(versionId)
|
||||
.orElseThrow(() -> new IOException("Cannot parse the version of " + versionId));
|
||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(repository.getResolvedPreservingPatchesVersion(versionId), gameVersion);
|
||||
List<ServerModpackManifest.Addon> addons = new ArrayList<>();
|
||||
addons.add(new ServerModpackManifest.Addon(MINECRAFT.getPatchId(), gameVersion));
|
||||
analyzer.getVersion(FORGE).ifPresent(forgeVersion ->
|
||||
|
||||
Reference in New Issue
Block a user