Skip to content

Commit

Permalink
Update getJavaVersionForMC(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
srnyx committed Jun 25, 2024
1 parent eec8552 commit ac32cc1
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,21 @@ 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
*
* @return The [JavaVersion] that is required for the Minecraft version
*/
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
}

Expand Down

0 comments on commit ac32cc1

Please sign in to comment.