diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 4c91a49de..8c93ef82a 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -523,20 +523,18 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } public function sendCommandData(){ - $pk = new AvailableCommandsPacket(); $data = new \stdClass(); $count = 0; foreach($this->server->getCommandMap()->getCommands() as $command){ - //TODO: fix command permission checks on join - /*if(!$command->testPermissionSilent($this)){ - continue; - }*/ - ++$count; - $data->{$command->getName()}->versions[0] = $command->generateCustomCommandData($this); + if(($cmdData = $command->generateCustomCommandData($this)) !== null){ + ++$count; + $data->{$command->getName()}->versions[0] = $cmdData; + } } if($count > 0){ //TODO: structure checking + $pk = new AvailableCommandsPacket(); $pk->commands = json_encode($data); $this->dataPacket($pk); } diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index d8b1fdd3c..26c765e21 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -470,9 +470,18 @@ namespace pocketmine { exit(1); //Exit with error } - if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information! - define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); - }else{ //Unknown :( + if(file_exists(\pocketmine\PATH . ".git/HEAD")){ //Found Git information! + $ref = trim(file_get_contents(\pocketmine\PATH . ".git/HEAD")); + if(preg_match('/^[0-9a-f]{40}$/i', $ref)){ + define('pocketmine\GIT_COMMIT', strtolower($ref)); + }elseif(substr($ref, 0, 5) === "ref: "){ + $refFile = \pocketmine\PATH . ".git/" . substr($ref, 5); + if(is_file($refFile)){ + define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents($refFile)))); + } + } + } + if(!defined('pocketmine\GIT_COMMIT')){ //Unknown :( define('pocketmine\GIT_COMMIT', str_repeat("00", 20)); } diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index 7a621a004..174a2a786 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -108,13 +108,13 @@ abstract class Command{ */ public function generateCustomCommandData(Player $player){ //TODO: fix command permission filtering on join - /*if(!$this->testPermission($player)){ + /*if(!$this->testPermissionSilent($player)){ return null; }*/ $customData = clone $this->commandData; $customData->aliases = $this->getAliases(); /*foreach($customData->overloads as &$overload){ - if(($p = @$overload->pocketminePermission) !== null and !$player->hasPermission($p)){ + if(isset($overload->pocketminePermission) and !$player->hasPermission($overload->pocketminePermission)){ unset($overload); } }*/