Add a check to ensure the correct mc version is being used with the correct yarn version.

This only applies to yarn mappings as there isnt a solid way to do this for other mappings.
dev/0.11
modmuss50 2020-05-11 13:20:12 +01:00
parent ac86ff1f29
commit 689293f52c
1 changed files with 12 additions and 2 deletions

View File

@ -95,10 +95,20 @@ public class MappingsProvider extends DependencyProvider {
File mappingsJar = dependency.resolveFile().orElseThrow(() -> new RuntimeException("Could not find yarn mappings: " + dependency));
this.mappingsName = StringUtils.removeSuffix(dependency.getDependency().getGroup() + "." + dependency.getDependency().getName(), "-unmerged");
this.minecraftVersion = minecraftProvider.getMinecraftVersion();
// Only do this for official yarn, there isn't really a way we can get the mc version for all mappings
if (dependency.getDependency().getGroup() != null && dependency.getDependency().getGroup().equals("net.fabricmc") && dependency.getDependency().getName().equals("yarn") && dependency.getDependency().getVersion() != null) {
String yarnVersion = dependency.getDependency().getVersion();
char separator = yarnVersion.contains("+build.") ? '+' : yarnVersion.contains("-") ? '-' : '.';
String yarnMinecraftVersion = yarnVersion.substring(0, yarnVersion.lastIndexOf(separator));
if (!yarnMinecraftVersion.equalsIgnoreCase(minecraftVersion)) {
throw new RuntimeException(String.format("Minecraft Version (%s) does not match yarn's minecraft version (%s)", minecraftVersion, yarnMinecraftVersion));
}
}
boolean isV2 = doesJarContainV2Mappings(mappingsJar.toPath());
this.minecraftVersion = minecraftProvider.getMinecraftVersion();
this.mappingsVersion = version + (isV2 ? "-v2" : "");
initFiles();