From 456b4b217f0069d72d61fd29f60ffd93147e05b0 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 4 Jun 2020 01:35:32 -0400 Subject: [PATCH] Run closeWith() logic in the event loop --- .../proxy/connection/MinecraftConnection.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index 91d99ceea..2765676e0 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -205,8 +205,10 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { */ public void closeWith(Object msg) { if (channel.isActive()) { - knownDisconnect = true; - channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE); + channel.eventLoop().execute(() -> { + knownDisconnect = true; + channel.writeAndFlush(msg).addListener(ChannelFutureListener.CLOSE); + }); } }