Merge branch 'master' into mcpe-1.0

This commit is contained in:
Dylan K. Taylor 2017-01-27 16:58:53 +00:00
commit 478a62e17b
3 changed files with 19 additions and 12 deletions

View File

@ -523,20 +523,18 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
public function sendCommandData(){ public function sendCommandData(){
$pk = new AvailableCommandsPacket();
$data = new \stdClass(); $data = new \stdClass();
$count = 0; $count = 0;
foreach($this->server->getCommandMap()->getCommands() as $command){ foreach($this->server->getCommandMap()->getCommands() as $command){
//TODO: fix command permission checks on join if(($cmdData = $command->generateCustomCommandData($this)) !== null){
/*if(!$command->testPermissionSilent($this)){ ++$count;
continue; $data->{$command->getName()}->versions[0] = $cmdData;
}*/ }
++$count;
$data->{$command->getName()}->versions[0] = $command->generateCustomCommandData($this);
} }
if($count > 0){ if($count > 0){
//TODO: structure checking //TODO: structure checking
$pk = new AvailableCommandsPacket();
$pk->commands = json_encode($data); $pk->commands = json_encode($data);
$this->dataPacket($pk); $this->dataPacket($pk);
} }

View File

@ -470,9 +470,18 @@ namespace pocketmine {
exit(1); //Exit with error exit(1); //Exit with error
} }
if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information! if(file_exists(\pocketmine\PATH . ".git/HEAD")){ //Found Git information!
define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); $ref = trim(file_get_contents(\pocketmine\PATH . ".git/HEAD"));
}else{ //Unknown :( 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)); define('pocketmine\GIT_COMMIT', str_repeat("00", 20));
} }

View File

@ -108,13 +108,13 @@ abstract class Command{
*/ */
public function generateCustomCommandData(Player $player){ public function generateCustomCommandData(Player $player){
//TODO: fix command permission filtering on join //TODO: fix command permission filtering on join
/*if(!$this->testPermission($player)){ /*if(!$this->testPermissionSilent($player)){
return null; return null;
}*/ }*/
$customData = clone $this->commandData; $customData = clone $this->commandData;
$customData->aliases = $this->getAliases(); $customData->aliases = $this->getAliases();
/*foreach($customData->overloads as &$overload){ /*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); unset($overload);
} }
}*/ }*/