From 713ee753e4083d6d53a36a7b7942a3200cd9c2a5 Mon Sep 17 00:00:00 2001 From: SOFe Date: Fri, 27 Jan 2017 18:49:54 +0800 Subject: [PATCH 1/3] Fixed wrong git commit hash parsing, fixes #295, closes #297 (#299) --- src/pocketmine/PocketMine.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 9bae8be4d..8b9d83a97 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)); } From 69d6d24a38f766cd2adae6c7eacf27441cbf526b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 27 Jan 2017 10:53:49 +0000 Subject: [PATCH 2/3] Removed use of stfu operator --- src/pocketmine/command/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index c8163c79c..d81ce2d2b 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -114,7 +114,7 @@ abstract class Command{ $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); } }*/ From 9661d845bbfcafba7690bf5f008ed48c2c4a02ac Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 27 Jan 2017 11:21:21 +0000 Subject: [PATCH 3/3] Fix some command stupidity This is why NOT to write code at 11PM when one is shattered. --- src/pocketmine/Player.php | 12 +++++------- src/pocketmine/command/Command.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 188395d01..168cfde66 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -507,20 +507,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/command/Command.php b/src/pocketmine/command/Command.php index d81ce2d2b..f329b1c15 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -108,7 +108,7 @@ 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;