diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch new file mode 100644 index 0000000000..9c3a79df96 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -4,8 +4,14 @@ + import net.minecraft.CrashReport; + import net.minecraft.ReportedException; + import net.minecraft.network.PacketListener; +-import net.minecraft.server.RunningOnDifferentThreadException; ++import net.minecraft.server.CancelledPacketHandleException; ++import org.slf4j.Logger; ++ ++// CraftBukkit start ++import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ServerLevel; ++import net.minecraft.server.network.ServerCommonPacketListenerImpl; ++// CraftBukkit end + import net.minecraft.util.thread.BlockableEventLoop; + import org.slf4j.Logger; + +@@ -18,17 +26,19 @@ + + public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException { + if (!executor.isSameThread()) { +- executor.executeIfPossible( +- () -> { +- if (processor.shouldHandleMessage(packet)) { +- try { +- packet.handle(processor); +- } catch (Exception var6) { +- if (var6 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError +- || processor.shouldPropagateHandlingExceptions()) { +- if (var6 instanceof ReportedException reportedException1) { +- processor.fillCrashReport(reportedException1.getReport()); +- throw var6; ++ executor.executeIfPossible(() -> { ++ if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) return; // CraftBukkit, MC-142590 ++ if (processor.shouldHandleMessage(packet)) { ++ try { ++ packet.handle(processor); ++ } catch (Exception exception) { ++ label25: ++ { ++ if (exception instanceof ReportedException) { ++ ReportedException reportedexception = (ReportedException) exception; ++ ++ if (reportedexception.getCause() instanceof OutOfMemoryError) { ++ break label25; + } + + CrashReport crashReport = CrashReport.forThrowable(var6, "Main thread packet handler"); +@@ -42,8 +63,13 @@ + LOGGER.debug("Ignoring packet due to disconnection: {}", packet); + } + } +- ); +- throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; ++ ++ }); ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit start - SPIGOT-5477, MC-142590 ++ } else if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) { ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit end + } + } + } |