diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index dd4e5866e..5bbff9b9d 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -1923,15 +1923,6 @@ 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"; @@ -1945,6 +1936,19 @@ 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); @@ -2800,7 +2804,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } public function handleEntityFall(EntityFallPacket $packet) : bool{ - return false; + return true; //not used } public function handleHurtArmor(HurtArmorPacket $packet) : bool{ @@ -3404,14 +3408,16 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $timings->startTiming(); $packet->decode(); - 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))); - } + $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 6662e2e88..7413711e4 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -50,12 +50,9 @@ class LoginPacket extends DataPacket{ public function decode(){ $this->protocol = $this->getInt(); + } - if($this->protocol !== ProtocolInfo::CURRENT_PROTOCOL){ - $this->buffer = null; - return; //Do not attempt to decode for non-accepted protocols - } - + public function decodeAdditional(){ $this->gameEdition = $this->getByte(); $this->setBuffer($this->getString(), 0); diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index aba41363b..ec1aaf822 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -754,8 +754,15 @@ class PluginManager{ if($class->isAbstract()){ throw new PluginException($event . " is an abstract Event"); } - if($class->getProperty("handlerList")->getDeclaringClass()->getName() !== $event){ - throw new PluginException($event . " does not have a handler list"); + + if(!$class->hasProperty("handlerList") or ($property = $class->getProperty("handlerList"))->getDeclaringClass()->getName() !== $event){ + throw new PluginException($event . " does not have a valid handler list"); + } + if(!$property->isStatic()){ + throw new PluginException($event . " handlerList property is not static"); + } + if(!$property->isPublic()){ + throw new PluginException($event . " handlerList property is not public"); } if(!$plugin->isEnabled()){