From aecff7c782f9700beaace01b62c18ed974b0e40b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 21 May 2017 13:27:27 +0100 Subject: [PATCH] Revert "Improved handling of incompatible protocols" This reverts commit 576702ffa97e16b1ca4cdee7d94460c661347ca7. This crippled plugins which use data fromm LoginPacket :S --- src/pocketmine/Player.php | 27 +++++++------------ .../network/mcpe/protocol/LoginPacket.php | 7 +++-- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index b4ffe0c1f..b9809f763 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1907,6 +1907,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return false; } + $this->username = TextFormat::clean($packet->username); + $this->displayName = $this->username; + $this->iusername = strtolower($this->username); + $this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false); + + if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){ + return true; + } + if($packet->protocol !== ProtocolInfo::CURRENT_PROTOCOL){ if($packet->protocol < ProtocolInfo::CURRENT_PROTOCOL){ $message = "disconnectionScreen.outdatedClient"; @@ -1920,19 +1929,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return true; } - $packet->decodeAdditional(); - - //TODO: check MCEE - - $this->username = TextFormat::clean($packet->username); - $this->displayName = $this->username; - $this->iusername = strtolower($this->username); - $this->setDataProperty(self::DATA_NAMETAG, self::DATA_TYPE_STRING, $this->username, false); - - if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){ - return true; - } - $this->randomClientId = $packet->clientId; $this->uuid = UUID::fromString($packet->clientUUID); @@ -3369,16 +3365,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $timings->startTiming(); $packet->decode(); + assert($packet->feof(), "Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet)); $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet)); if(!$ev->isCancelled() and !$packet->handle($this)){ $this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->getName() . ": 0x" . bin2hex($packet->buffer)); } - if(!$packet->feof()){ - $this->server->getLogger()->debug("Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet) . " from " . $this->getName() . ": " . bin2hex($packet->get(true))); - } - $timings->stopTiming(); } diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index be249eb03..b8a596475 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -54,9 +54,12 @@ class LoginPacket extends DataPacket{ public function decode(){ $this->protocol = $this->getInt(); - } - public function decodeAdditional(){ + if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){ + $this->buffer = null; + return; //Do not attempt to decode for non-accepted protocols + } + $this->gameEdition = $this->getByte(); $str = zlib_decode($this->getString(), 1024 * 1024 * 64);