From cd3db4ae8c9f47b0f2e94dfd441cfc544920457c Mon Sep 17 00:00:00 2001 From: Roberta001 <112218924+Roberta001@users.noreply.github.com> Date: Tue, 9 Jun 2026 16:17:13 +0800 Subject: [PATCH] Fix bot connection region crash (#149) * Fix: bot connection causing region crash, fix readme * Fix NPE on Region Shutdown with bots * simple fix up * Revert "Fix NPE on Region Shutdown with bots" This reverts commit b55c982cb92e6a17d271a036ee661c0beb8cabb3. * Revert "fix: fix a bug in server shutdown with fakeplayer" This reverts commit a721c27e96342c483a7cc59610f6ff26383f88be. * fix: improve bot shutdown handling to prevent region crashes --------- Co-authored-by: Helvetica Volubi --- README.md | 2 +- README_EN.md | 2 +- .../features/0030-Leaves-Fakeplayer.patch | 51 ++++++++++++++----- .../features/0031-Leaves-Replay-Mod-API.patch | 12 ++--- ...eaves-Catch-update-suppression-crash.patch | 4 +- .../java/org/leavesmc/leaves/bot/BotList.java | 8 ++- .../bot/ServerBotPacketListenerImpl.java | 13 +++-- 7 files changed, 65 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 598bcd3..b372e5b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ git clone https://github.com/LuminolMC/Lophine.git cd Lophine # 应用补丁并构建 Paperclip JAR -./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar +./gradlew applyAllPatches && ./gradlew createPaperclipJar ``` 构建完成后,您可以在 `lophine-server/build/libs` 目录中找到生成的 JAR 文件。 diff --git a/README_EN.md b/README_EN.md index 7fa1043..baf2067 100644 --- a/README_EN.md +++ b/README_EN.md @@ -45,7 +45,7 @@ git clone https://github.com/LuminolMC/Lophine.git cd Lophine # Apply patches and build Paperclip JAR -./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar +./gradlew applyAllPatches && ./gradlew createPaperclipJar ``` After building, you can find the generated JAR file in the `lophine-server/build/libs` directory. diff --git a/lophine-server/minecraft-patches/features/0030-Leaves-Fakeplayer.patch b/lophine-server/minecraft-patches/features/0030-Leaves-Fakeplayer.patch index e40acba..c18cf23 100644 --- a/lophine-server/minecraft-patches/features/0030-Leaves-Fakeplayer.patch +++ b/lophine-server/minecraft-patches/features/0030-Leaves-Fakeplayer.patch @@ -33,7 +33,7 @@ index efbbc1a40d203a2818eeda2a4e938b9a6117f1c3..6b85a5ad9af0c57a0d4d5b55f62b82c5 private boolean encrypted; private final java.util.concurrent.atomic.AtomicBoolean disconnectionHandled = new java.util.concurrent.atomic.AtomicBoolean(false); // Folia - region threading - may be called concurrently during configuration stage diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 9e290fa626caffac148920c54479a75ad0919e70..54eaf4f7f8cf728d5d02d88de8d57d88504bc46d 100644 +index 9e290fa626caffac148920c54479a75ad0919e70..75d93d7d8bc6077dd80e499cd43327a4afe58f51 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -297,6 +297,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(final Function factory) { ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system AtomicReference serverReference = new AtomicReference<>(); -@@ -1120,6 +1122,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy @@ -62,7 +71,7 @@ index 9e290fa626caffac148920c54479a75ad0919e70..54eaf4f7f8cf728d5d02d88de8d57d88 this.emptyTicks++; } else { this.emptyTicks = 0; -@@ -1827,6 +1830,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { this.playerList.saveAll(playerSaveInterval); @@ -70,7 +79,7 @@ index 9e290fa626caffac148920c54479a75ad0919e70..54eaf4f7f8cf728d5d02d88de8d57d88 } if (region == null && fullSave) { // Folia - region threading - don't auto save level data this.saveGlobalData(false); -@@ -2065,6 +2069,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Component.translatable("commands.stop.stopping"), true); + c.getSource().getServer().halt(false); + return 1; +- })); ++ }).then(Commands.literal("force").requires(Commands.hasPermission(Commands.LEVEL_OWNERS)).executes(c -> { ++ c.getSource().sendSuccess(() -> Component.translatable("commands.stop.stopping"), true); ++ c.getSource().getServer().safeShutdown(false, false, true); ++ return 1; ++ }))); + } + } diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java index 1bc1e9a77dca7acfe5f989f6439f185d0d2e20a6..1790e8c141a8d3f7ccf4b11f9a28b3582325e317 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java diff --git a/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch b/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch index e25b06b..008d460 100644 --- a/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch +++ b/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch @@ -84,10 +84,10 @@ index 7e3912b8b29e40eb3347f1451b0fd3ebee2af4f1..0834e402e6af7028e08851378e15390e result.add(player); if (result.size() >= limit) { diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 54eaf4f7f8cf728d5d02d88de8d57d88504bc46d..269b884ff30d908f772d1c0cf05076e359bcdd7e 100644 +index 75d93d7d8bc6077dd80e499cd43327a4afe58f51..3b9a4f4b5794faa4955018858c94fd5c2d6ada3d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1921,7 +1921,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Folia - region threading // Paper start - Expand PlayerGameModeChangeEvent org.bukkit.event.player.PlayerGameModeChangeEvent event = updatedPlayer.setGameMode(gameType, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null); // Folia - region threading -@@ -2541,7 +2541,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop