public function processBatch(BatchPacket $packet, Player $p) { $str = zlib_decode($packet->payload, 1024 * 1024 * 64); //Max 64MB $len = strlen($str); $offset = 0; try { while ($offset < $len) { $pkLen = Binary::readInt(substr($str, $offset, 4)); $offset += 4; $buf = substr($str, $offset, $pkLen); $offset += $pkLen; if (($pk = $this->getPacket(ord($buf[0]))) !== null) { if ($pk::NETWORK_ID === Info::BATCH_PACKET) { throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } $pk->setBuffer($buf, 1); $pk->decode(); $p->handleDataPacket($pk); if ($pk->getOffset() <= 0) { return; } } } } catch (\Exception $e) { if (\BukkitPE\DEBUG > 1) { $logger = $this->server->getLogger(); if ($logger instanceof MainLogger) { $logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload)); $logger->logException($e); } } } }