mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Prevent executing commands if server stopped
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 29 Sep 2025 03:28:55 -0400
|
||||
Subject: [PATCH] Prevent executing commands if server stopped
|
||||
|
||||
The server is executing player's commands when server stopped, but the player didn't disconnect.
|
||||
Since the server is stopped, the commands execute on current thread instead of the main thread.
|
||||
|
||||
It's a kind of weird race condition, not sure what causes it,
|
||||
so just add a `isStopped` check, like the check under `handleChat`
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 581791bf2892715543f003c36e301e690cc393f1..0d7a00a7865dd79a2aaec6b1060e763e5815f12a 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2369,7 +2369,7 @@ public class ServerGamePacketListenerImpl
|
||||
final boolean isAfkCommandCooldown = this.performAfkCooldown(packet.command()); // Leaf - Improve Purpur AFK system
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
// CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands
|
||||
- if (this.player.hasDisconnected()) {
|
||||
+ if (this.player.hasDisconnected() || this.server.isStopped()) { // Leaf - Prevent executing commands if server stopped
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -2411,7 +2411,7 @@ public class ServerGamePacketListenerImpl
|
||||
final boolean isAfkCommandCooldown = this.performAfkCooldown(packet.command()); // Leaf - Improve Purpur AFK system
|
||||
this.tryHandleChat(packet.command(), () -> {
|
||||
// CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands
|
||||
- if (this.player.hasDisconnected()) {
|
||||
+ if (this.player.hasDisconnected() || this.server.isStopped()) { // Leaf - Prevent executing commands if server stopped
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
Reference in New Issue
Block a user