diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index bb1f321f7..b06ba10e7 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -440,6 +440,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } $this->recalculatePermissions(); + $this->sendCommandData(); } /** @@ -503,6 +504,19 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return $this->perm->getEffectivePermissions(); } + public function sendCommandData(){ + $pk = new AvailableCommandsPacket(); + $data = []; + foreach($this->server->getCommandMap()->getCommands() as $command){ + $data[$command->getName()] = $command->generateJsonData($this); + } + if(count($data) > 0){ + //TODO: structure checking + $pk->commands = json_encode($data); + $this->dataPacket($pk); + } + } + /** * @param SourceInterface $interface * @param null $clientID @@ -1713,14 +1727,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($this->isOp()){ $this->setRemoveFormat(false); } - - $pk = new AvailableCommandsPacket(); - $data = []; - foreach($this->server->getCommandMap()->getCommands() as $command){ - $data[$command->getName()] = $command->generateJsonData($this); - } - $pk->commands = json_encode($data); - $this->dataPacket($pk); + + $this->sendCommandData(); if($this->isCreative()){ $this->inventory->sendCreativeContents();