From 3e1e1def8d60da1ce4eac7c8a0ce60d5e0c1dde1 Mon Sep 17 00:00:00 2001 From: neonf Date: Fri, 2 Aug 2024 23:35:12 +0700 Subject: [PATCH] Small fix --- src/lgsl_protocol.php | 10 +++++++++- tests/mockedServersTest.php | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lgsl_protocol.php b/src/lgsl_protocol.php index 6d2a74a..1baf17b 100644 --- a/src/lgsl_protocol.php +++ b/src/lgsl_protocol.php @@ -489,9 +489,17 @@ abstract function process(); public function execute(): int { $time = microtime(true); $status = $this->process(); - if ($status === $this::SUCCESS && $this->separatedPackets) { + if ($status === $this::SUCCESS) { + if ($this->separatedPackets) { if ($this->_need['e']) $status |= $this->process(); if ($this->_need['p']) $status |= $this->process(); + } else { + $this->_need = [ + 's' => false, + 'e' => false, + 'p' => false + ]; + } } $this->_data['o']['time_execution'] = $time - microtime(true); if ($status !== $this::NO_RESPOND) { diff --git a/tests/mockedServersTest.php b/tests/mockedServersTest.php index 4c64373..8fdab3e 100644 --- a/tests/mockedServersTest.php +++ b/tests/mockedServersTest.php @@ -15,6 +15,7 @@ public function readRaw($length = 4096) { function example($type) { $list = [ Protocol::MINECRAFTPE => "[null][null][null][null][null]6��[null]c�wV4�[null]��[null]��������4Vx[null]^MCPE;§r§eLGSLSERVERNAME;649;1.20.60;34;500;63020977098711111;Bedrock Edition;Survival;1;19132;19132;", + Protocol::UNVANQUISHED => "....statusResponse\n\gamename\base\mapname\utcs\protocol\86\sv_hostname\^1LGSLSERVERNAME\sv_maxRate\\0\sv_maxclients\\64\\timelimit\\60\\version\Unvanquished\n140 0 \"^9[bot]^iDengos\"\n89 0 \"^9[bot]^dEjim\"", ]; return $list[$type]; } @@ -23,7 +24,7 @@ class LGSLMockedTest extends TestCase { public function testMockedServers() { echo("\nTesting mocked servers"); ob_flush(); - foreach ([Protocol::MINECRAFTPE] as $type) { + foreach ([Protocol::MINECRAFTPE, Protocol::UNVANQUISHED] as $type) { $server = new Server(["ip" => "LgslServerIp.com", "c_port" => 25565, "q_port" => 25565, "type" => $type]); $protocol = new Protocol($server, null); $query = "tltneon\LGSL\\" . $protocol->lgslProtocolClass($server->getType());