From b83fcbf2fc9b00a1a0317dae4e88166ccd086c08 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Dec 2025 05:07:32 +0000 Subject: [PATCH 1/3] feat: upgrade to Minecraft 1.21.11 support - Update spigotVersion to 1.21.11-R0.1-SNAPSHOT in pom.xml - Update plugin version to 1.3-mc1_21_11 - Update BuildTools --rev to 1.21.11 in release.yml - Update CLAUDE.md documentation to reflect new version --- .github/workflows/release.yml | 2 +- CLAUDE.md | 32 ++++++++++++++++---------------- pom.xml | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8957fba..ece9e35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: mkdir -p buildtools cd buildtools wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar - java -jar BuildTools.jar --rev 1.21.10 --remapped + java -jar BuildTools.jar --rev 1.21.11 --remapped cd .. timeout-minutes: 30 diff --git a/CLAUDE.md b/CLAUDE.md index 20ad409..3344e82 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,10 +5,10 @@ **DynamicSpigotSetting** is a Minecraft Spigot/Paper plugin that dynamically adjusts server performance settings based on real-time TPS (Ticks Per Second) monitoring. The plugin automatically modifies item and experience orb merge radii to help maintain server performance during high load situations. - **Plugin Name**: DynamicSpigotSetting -- **Version**: 1.3-mc1_21_10 +- **Version**: 1.3-mc1_21_11 - **Package**: cf.catworlds.dynamicspigotsetting - **Author**: WhiteCat -- **Minecraft Version**: 1.21.10 +- **Minecraft Version**: 1.21.11 - **Java Version**: 21 - **Build Tool**: Maven - **API**: Spigot/Paper API with NMS (Net Minecraft Server) access @@ -195,11 +195,11 @@ TextHelper.format(BasicText.ItemMergeCommand, 2.5) **Dependencies**: 1. **Paper API** (provided scope): - - Artifact: `io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT` + - Artifact: `io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT` - Used for Bukkit/Spigot API access and Paper-specific features like `getTPS()` 2. **Spigot NMS** (provided scope): - - Artifact: `org.spigotmc:spigot:1.21.10-R0.1-SNAPSHOT:remapped-mojang` + - Artifact: `org.spigotmc:spigot:1.21.11-R0.1-SNAPSHOT:remapped-mojang` - Used for direct server internals access (MinecraftServer, WorldServer) **Build Process**: @@ -251,7 +251,7 @@ mvn clean 2. Set up JDK 21 (Temurin distribution) with Maven cache 3. **Build Spigot with BuildTools** (30-minute timeout): - Downloads latest BuildTools.jar - - Builds Spigot 1.21.10 with remapped sources + - Builds Spigot 1.21.11 with remapped sources - Required for NMS dependencies 4. Build with Maven (`mvn clean package`) 5. Find final JAR (excludes `remapped-obf.jar` and `original-` prefix) @@ -286,7 +286,7 @@ mvn clean 4. **Local Testing**: - Copy `target/DynamicSpigotSetting-*-remapped.jar` to test server's `plugins/` folder - - Requires Spigot or Paper 1.21.10 server + - Requires Spigot or Paper 1.21.11 server ### Making Code Changes @@ -426,8 +426,8 @@ new BukkitRunnable() { ### Version Compatibility -**Current Version**: 1.21.10 -- Built against Spigot 1.21.10-R0.1-SNAPSHOT +**Current Version**: 1.21.11 +- Built against Spigot 1.21.11-R0.1-SNAPSHOT - Uses Mojang mappings (remapped-mojang classifier) **When Updating Minecraft Version**: @@ -650,12 +650,12 @@ try { ### Current Versions -- **Minecraft**: 1.21.10 +- **Minecraft**: 1.21.11 - **Java**: 21 - **Maven Compiler**: 3.13.0 - **SpecialSource**: 2.0.3 -- **Paper API**: 1.21.10-R0.1-SNAPSHOT -- **Spigot**: 1.21.10-R0.1-SNAPSHOT +- **Paper API**: 1.21.11-R0.1-SNAPSHOT +- **Spigot**: 1.21.11-R0.1-SNAPSHOT ### Updating Dependencies @@ -706,8 +706,8 @@ try { ### Server Compatibility Testing Test on: -- [ ] Latest Spigot 1.21.10 -- [ ] Latest Paper 1.21.10 +- [ ] Latest Spigot 1.21.11 +- [ ] Latest Paper 1.21.11 - [ ] With other plugins (check conflicts) - [ ] With low TPS simulation - [ ] After server restart (config persistence) @@ -722,7 +722,7 @@ Test on: 1. Ensure `~/.m2/repository` has Spigot artifacts 2. Run BuildTools manually: ```bash - java -jar BuildTools.jar --rev 1.21.10 --remapped + java -jar BuildTools.jar --rev 1.21.11 --remapped ``` 3. Retry build @@ -973,6 +973,6 @@ mvn clean package --- -**Last Updated**: 2025-11-15 +**Last Updated**: 2025-12-11 **For**: AI Assistant Claude -**Project Version**: 1.3-mc1_21_10 +**Project Version**: 1.3-mc1_21_11 diff --git a/pom.xml b/pom.xml index 793bf01..6ef49e4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,10 +4,10 @@ cf.catworlds DynamicSpigotSetting DynamicSpigotSetting - 1.3-mc1_21_10 + 1.3-mc1_21_11 - 1.21.10-R0.1-SNAPSHOT + 1.21.11-R0.1-SNAPSHOT UTF-8 21 From a322c10ff2ddc88bb4e83e44048a3a5357eb2ad1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Dec 2025 07:39:27 +0000 Subject: [PATCH 2/3] fix: use Bukkit API instead of NMS getAllLevels() for world iteration MinecraftServer.getAllLevels() obfuscated method name changed in 1.21.11. Switch to using Bukkit.getWorlds() with CraftWorld.getHandle() which is more stable across version updates. --- .../utils/ServerHelper.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java b/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java index 67f7632..ef4934f 100644 --- a/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java +++ b/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java @@ -1,7 +1,8 @@ package cf.catworlds.dynamicspigotsetting.utils; -import net.minecraft.server.MinecraftServer; import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.craftbukkit.CraftWorld; public class ServerHelper { @@ -11,22 +12,28 @@ static public double getTPS() { @SuppressWarnings("deprecation") static public double getItemMerge() { - return MinecraftServer.getServer().getAllLevels().iterator().next().spigotConfig.itemMerge; + World world = Bukkit.getWorlds().get(0); + return ((CraftWorld) world).getHandle().spigotConfig.itemMerge; } @SuppressWarnings("deprecation") static public void setItemMerge(double radius) { - MinecraftServer.getServer().getAllLevels().forEach((ws) -> ws.spigotConfig.itemMerge = radius); + for (World world : Bukkit.getWorlds()) { + ((CraftWorld) world).getHandle().spigotConfig.itemMerge = radius; + } } @SuppressWarnings("deprecation") static public double getExpMerge() { - return MinecraftServer.getServer().getAllLevels().iterator().next().spigotConfig.expMerge; + World world = Bukkit.getWorlds().get(0); + return ((CraftWorld) world).getHandle().spigotConfig.expMerge; } @SuppressWarnings("deprecation") static public void setExpMerge(double radius) { - MinecraftServer.getServer().getAllLevels().forEach((ws) -> ws.spigotConfig.expMerge = radius); + for (World world : Bukkit.getWorlds()) { + ((CraftWorld) world).getHandle().spigotConfig.expMerge = radius; + } } } From 8c993b1588fdc71c6a2675b224212003a8e7c697 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Dec 2025 12:45:39 +0000 Subject: [PATCH 3/3] fix: use reflection to access CraftWorld.getHandle() and spigotConfig CraftWorld class is not available at compile time in CI environment. Use reflection to invoke getHandle() method and access spigotConfig field at runtime, avoiding compile-time dependency on CraftBukkit classes. --- .../utils/ServerHelper.java | 63 +++++++++++++++---- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java b/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java index ef4934f..18e5d2e 100644 --- a/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java +++ b/src/main/java/cf/catworlds/dynamicspigotsetting/utils/ServerHelper.java @@ -1,8 +1,9 @@ package cf.catworlds.dynamicspigotsetting.utils; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.craftbukkit.CraftWorld; public class ServerHelper { @@ -10,30 +11,66 @@ static public double getTPS() { return Bukkit.getServer().getTPS()[0]; } - @SuppressWarnings("deprecation") static public double getItemMerge() { - World world = Bukkit.getWorlds().get(0); - return ((CraftWorld) world).getHandle().spigotConfig.itemMerge; + try { + World world = Bukkit.getWorlds().get(0); + Object handle = getHandle(world); + Object spigotConfig = getSpigotConfig(handle); + Field itemMergeField = spigotConfig.getClass().getField("itemMerge"); + return itemMergeField.getDouble(spigotConfig); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } } - @SuppressWarnings("deprecation") static public void setItemMerge(double radius) { - for (World world : Bukkit.getWorlds()) { - ((CraftWorld) world).getHandle().spigotConfig.itemMerge = radius; + try { + for (World world : Bukkit.getWorlds()) { + Object handle = getHandle(world); + Object spigotConfig = getSpigotConfig(handle); + Field itemMergeField = spigotConfig.getClass().getField("itemMerge"); + itemMergeField.setDouble(spigotConfig, radius); + } + } catch (Exception e) { + e.printStackTrace(); } } - @SuppressWarnings("deprecation") static public double getExpMerge() { - World world = Bukkit.getWorlds().get(0); - return ((CraftWorld) world).getHandle().spigotConfig.expMerge; + try { + World world = Bukkit.getWorlds().get(0); + Object handle = getHandle(world); + Object spigotConfig = getSpigotConfig(handle); + Field expMergeField = spigotConfig.getClass().getField("expMerge"); + return expMergeField.getDouble(spigotConfig); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } } - @SuppressWarnings("deprecation") static public void setExpMerge(double radius) { - for (World world : Bukkit.getWorlds()) { - ((CraftWorld) world).getHandle().spigotConfig.expMerge = radius; + try { + for (World world : Bukkit.getWorlds()) { + Object handle = getHandle(world); + Object spigotConfig = getSpigotConfig(handle); + Field expMergeField = spigotConfig.getClass().getField("expMerge"); + expMergeField.setDouble(spigotConfig, radius); + } + } catch (Exception e) { + e.printStackTrace(); } } + private static Object getHandle(World world) throws Exception { + Method getHandle = world.getClass().getMethod("getHandle"); + return getHandle.invoke(world); + } + + private static Object getSpigotConfig(Object worldServer) throws Exception { + Field spigotConfigField = worldServer.getClass().getField("spigotConfig"); + return spigotConfigField.get(worldServer); + } + }