From 762d9a3efbc83a482bbdb3ee2632a90f1fe09750 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 7 Nov 2018 01:28:24 -0500 Subject: [PATCH] Fix plugin message forwarding from server to client. --- .../backend/BackendPlaySessionHandler.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 8f87e593b..5bcc76653 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -84,11 +84,6 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(PluginMessage packet) { - MinecraftConnection smc = serverConn.getConnection(); - if (smc == null) { - return true; - } - if (!canForwardPluginMessage(packet)) { return true; } @@ -117,14 +112,15 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { return false; } + MinecraftConnection clientConn = serverConn.getPlayer().getConnection(); PluginMessageEvent event = new PluginMessageEvent(serverConn, serverConn.getPlayer(), id, packet.getData()); server.getEventManager().fire(event) .thenAcceptAsync(pme -> { - if (pme.getResult().isAllowed() && serverConn.isActive()) { - smc.write(packet); + if (pme.getResult().isAllowed() && !clientConn.isClosed()) { + clientConn.write(packet); } - }, smc.eventLoop()); + }, clientConn.eventLoop()); return true; }