|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Mon, 29 Sep 2025 03:28:55 -0400 |
| 4 | +Subject: [PATCH] Prevent executing commands if server stopped |
| 5 | + |
| 6 | +The server is executing player's commands when server stopped, but the player didn't disconnect. |
| 7 | +Since the server is stopped, the commands execute on current thread instead of the main thread. |
| 8 | + |
| 9 | +It's a kind of weird race condition, not sure what causes it, |
| 10 | +so just add a `isStopped` check, like the check under `handleChat` |
| 11 | + |
| 12 | +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 13 | +index 581791bf2892715543f003c36e301e690cc393f1..0d7a00a7865dd79a2aaec6b1060e763e5815f12a 100644 |
| 14 | +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 15 | ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java |
| 16 | +@@ -2369,7 +2369,7 @@ public class ServerGamePacketListenerImpl |
| 17 | + final boolean isAfkCommandCooldown = this.performAfkCooldown(packet.command()); // Leaf - Improve Purpur AFK system |
| 18 | + this.tryHandleChat(packet.command(), () -> { |
| 19 | + // CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands |
| 20 | +- if (this.player.hasDisconnected()) { |
| 21 | ++ if (this.player.hasDisconnected() || this.server.isStopped()) { // Leaf - Prevent executing commands if server stopped |
| 22 | + return; |
| 23 | + } |
| 24 | + // CraftBukkit end |
| 25 | +@@ -2411,7 +2411,7 @@ public class ServerGamePacketListenerImpl |
| 26 | + final boolean isAfkCommandCooldown = this.performAfkCooldown(packet.command()); // Leaf - Improve Purpur AFK system |
| 27 | + this.tryHandleChat(packet.command(), () -> { |
| 28 | + // CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands |
| 29 | +- if (this.player.hasDisconnected()) { |
| 30 | ++ if (this.player.hasDisconnected() || this.server.isStopped()) { // Leaf - Prevent executing commands if server stopped |
| 31 | + return; |
| 32 | + } |
| 33 | + // CraftBukkit end |
0 commit comments