From ac32cc1f2ba49d9bff228320df59d4e1ef12fd9d Mon Sep 17 00:00:00 2001 From: srnyx <25808801+srnyx@users.noreply.github.com> Date: Tue, 25 Jun 2024 13:54:22 -0400 Subject: [PATCH] Update `getJavaVersionForMC(...)` --- .../xyz/srnyx/gradlegalaxy/utility/Dependencies.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt index 8e452fa..bd6d1d0 100644 --- a/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt +++ b/src/main/kotlin/xyz/srnyx/gradlegalaxy/utility/Dependencies.kt @@ -187,6 +187,10 @@ fun DependencyHandler.implementationRelocate( /** * Returns the correct Java version that is required for the Minecraft version + * - 1.20.5+: Java 21 + * - 1.18+: Java 17 + * - 1.17+: Java 16 + * - Else: Java 8 * * @param minecraftVersion The Minecraft version to get the Java version for * @@ -194,7 +198,10 @@ fun DependencyHandler.implementationRelocate( */ fun getJavaVersionForMC(minecraftVersion: String): JavaVersion? { val version = SemanticVersion(minecraftVersion) - if (version.major != 1 || version.minor >= 18) return null + if (version.major != 1) return null + if (version.minor >= 20 && version.patch >= 5) return JavaVersion.VERSION_21 + if (version.minor >= 18) return JavaVersion.VERSION_17 + if (version.minor >= 17) return JavaVersion.VERSION_16 return JavaVersion.VERSION_1_8 }