From 80832ff763b415212c63027588e8ec9fae991dd8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 24 Dec 2022 20:12:50 +0000 Subject: [PATCH] NetworkSession: do not send packets to disconnected sessions this is mostly harmless, since the packets land in a buffer that gets discarded, but we also need to avoid calling DataPacketSendEvent. --- src/network/mcpe/NetworkSession.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index a765815f0..57eb1f699 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -424,6 +424,9 @@ class NetworkSession{ } public function sendDataPacket(ClientboundPacket $packet, bool $immediate = false) : bool{ + if(!$this->connected){ + return false; + } //Basic safety restriction. TODO: improve this if(!$this->loggedIn && !$packet->canBeSentBeforeLogin()){ throw new \InvalidArgumentException("Attempted to send " . get_class($packet) . " to " . $this->getDisplayName() . " too early");