From 70e8f2e764de375e4ae9942e2ee22916b63d60eb Mon Sep 17 00:00:00 2001 From: Dominik Suliga Date: Wed, 26 Aug 2026 10:40:03 +0200 Subject: [PATCH] fix(build): target Java 21 bytecode so 1.21 servers can load the plugin #175 raised both the toolchain and the release to 25, which emits class file 69 and makes the plugin unloadable on any JVM below 25. Minecraft 1.21 requires Java 21, so stock servers at the low end of the supported range would fail with UnsupportedClassVersionError despite the API compatibility work in that PR. Nothing in the dependency chain justified the higher target: the Spigot API is class file 61 in both 1.21 and 26.2, and the highest bundled library is also 61. The sources use no language feature past 21 either. Keep building on JDK 25 and lower the emitted bytecode to 21 by splitting the single JAVA constant into JAVA_TOOLCHAIN and JAVA_RELEASE. The shipped jar now tops out at class file 65 and loads on Java 21 and newer. Co-Authored-By: Claude Opus 5 --- README.md | 4 ++-- buildSrc/src/main/kotlin/Versions.kt | 11 +++++++++-- buildSrc/src/main/kotlin/playtime-java.gradle.kts | 4 ++-- playtime-plugin/build.gradle.kts | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 054570d..269a3f6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ⏳ Advanced PlayTime Plugin [![Build Status](https://github.com/imDMK/AdvancedPlayTime/actions/workflows/gradle.yml/badge.svg)](https://github.com/imDMK/AdvancedPlayTime/actions/workflows/gradle.yml) -![JDK](https://img.shields.io/badge/JDK-25-blue.svg) +![JDK](https://img.shields.io/badge/JDK-21%2B-blue.svg) ![Supported versions](https://img.shields.io/badge/Minecraft-1.21--26.2-green.svg) [![SpigotMC](https://img.shields.io/badge/SpigotMC-yellow.svg)](https://www.spigotmc.org/resources/%E2%8F%B0%EF%B8%8F-advancedplaytime-1-21-1-21-10.130458/) [![Modrinth](https://img.shields.io/badge/Modrinth-1bd96a.svg)](https://modrinth.com/plugin/advancedplaytime) @@ -14,7 +14,7 @@ --- ### 📦 Requirements -- **Java 25** or newer on the server. +- **Java 21** or newer on the server. - **Spigot / Paper 1.21 – 26.2**. ### ✨ Key Features diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index e445c89..d194382 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -1,7 +1,14 @@ object Versions { - /** Java release the plugin is compiled for and requires at runtime. */ - const val JAVA = 25 + /** JDK the project is built with. */ + const val JAVA_TOOLCHAIN = 25 + + /** + * Bytecode level of the shipped plugin, and therefore the oldest JVM a server may + * run it on. Kept at 21 because that is what Minecraft 1.21 itself requires — a + * higher target would lock the plugin out of the low end of the supported range. + */ + const val JAVA_RELEASE = 21 /** Spigot API the plugin is compiled against (newest supported server). */ const val SPIGOT_API = "26.2-R0.1-SNAPSHOT" diff --git a/buildSrc/src/main/kotlin/playtime-java.gradle.kts b/buildSrc/src/main/kotlin/playtime-java.gradle.kts index 3336939..c79e5f5 100644 --- a/buildSrc/src/main/kotlin/playtime-java.gradle.kts +++ b/buildSrc/src/main/kotlin/playtime-java.gradle.kts @@ -6,11 +6,11 @@ group = "com.github.imdmk" version = "3.0.2" java { - toolchain.languageVersion.set(JavaLanguageVersion.of(Versions.JAVA)) + toolchain.languageVersion.set(JavaLanguageVersion.of(Versions.JAVA_TOOLCHAIN)) } tasks.withType().configureEach { options.compilerArgs = listOf("-Xlint:deprecation", "-parameters") options.encoding = "UTF-8" - options.release.set(Versions.JAVA) + options.release.set(Versions.JAVA_RELEASE) } diff --git a/playtime-plugin/build.gradle.kts b/playtime-plugin/build.gradle.kts index 4eb2380..6920070 100644 --- a/playtime-plugin/build.gradle.kts +++ b/playtime-plugin/build.gradle.kts @@ -30,7 +30,7 @@ playTimeShadow { } shadowJar { - archiveFileName.set("AdvancedPlayTime v${project.version} (MC 1.21-26.2, Java ${Versions.JAVA}).jar") + archiveFileName.set("AdvancedPlayTime v${project.version} (MC 1.21-26.2, Java ${Versions.JAVA_RELEASE}).jar") mergeServiceFiles()