2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
|
|
|
+++ b/net/minecraft/network/protocol/PlayerConnectionUtils.java
|
|
|
|
@@ -7,6 +7,11 @@
|
2022-02-28 16:00:00 +01:00
|
|
|
import net.minecraft.util.thread.IAsyncTaskHandler;
|
|
|
|
import org.slf4j.Logger;
|
2021-03-15 23:00:00 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import net.minecraft.server.MinecraftServer;
|
|
|
|
+import net.minecraft.server.network.PlayerConnection;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class PlayerConnectionUtils {
|
|
|
|
|
2022-02-28 16:00:00 +01:00
|
|
|
private static final Logger LOGGER = LogUtils.getLogger();
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -20,6 +25,7 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T t0, IAsyncTaskHandler<?> iasynctaskhandler) throws CancelledPacketHandleException {
|
|
|
|
if (!iasynctaskhandler.isSameThread()) {
|
2022-02-28 16:00:00 +01:00
|
|
|
iasynctaskhandler.executeIfPossible(() -> {
|
2019-05-05 01:25:51 +02:00
|
|
|
+ if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) return; // CraftBukkit, MC-142590
|
2023-03-14 17:30:00 +01:00
|
|
|
if (t0.isAcceptingMessages()) {
|
2022-02-28 16:00:00 +01:00
|
|
|
try {
|
|
|
|
packet.handle(t0);
|
|
|
|
@@ -36,6 +42,10 @@
|
2021-01-31 00:08:41 +01:00
|
|
|
|
2020-01-12 00:50:22 +01:00
|
|
|
});
|
2021-06-11 07:00:00 +02:00
|
|
|
throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
|
2021-01-31 00:08:41 +01:00
|
|
|
+ // CraftBukkit start - SPIGOT-5477, MC-142590
|
|
|
|
+ } else if (MinecraftServer.getServer().hasStopped() || (t0 instanceof PlayerConnection && ((PlayerConnection) t0).processedDisconnect)) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD;
|
2021-01-31 00:08:41 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2020-01-12 00:50:22 +01:00
|
|
|
}
|
|
|
|
}
|