75        if(!file_exists($this->path)){
 
   76            $logger->
debug(
"Resource packs path $path does not exist, creating directory");
 
   78        }elseif(!is_dir($this->path)){
 
   79            throw new \InvalidArgumentException(
"Resource packs path $path exists and is not a directory");
 
   82        $resourcePacksYml = Path::join($this->path, 
"resource_packs.yml");
 
   83        if(!file_exists($resourcePacksYml)){
 
   84            copy(Path::join(\
pocketmine\RESOURCE_PATH, 
"resource_packs.yml"), $resourcePacksYml);
 
   87        $resourcePacksConfig = 
new Config($resourcePacksYml, Config::YAML, []);
 
   89        $this->serverForceResources = (bool) $resourcePacksConfig->get(
"force_resources", 
false);
 
   91        $logger->
info(
"Loading resource packs...");
 
   93        $resourceStack = $resourcePacksConfig->get(
"resource_stack", []);
 
   94        if(!is_array($resourceStack)){
 
   95            throw new \InvalidArgumentException(
"\"resource_stack\" key should contain a list of pack names");
 
   98        foreach(Utils::promoteKeys($resourceStack) as $pos => $pack){
 
   99            if(!is_string($pack) && !is_int($pack) && !is_float($pack)){
 
  100                $logger->
critical(
"Found invalid entry in resource pack list at offset $pos of type " . gettype($pack));
 
  103            $pack = (string) $pack;
 
  105                $newPack = $this->loadPackFromPath(Path::join($this->path, $pack));
 
  107                $index = strtolower($newPack->getPackId());
 
  108                if(!Uuid::isValid($index)){
 
  113                $this->uuidList[$index] = $newPack;
 
  114                $this->resourcePacks[] = $newPack;
 
  116                $keyPath = Path::join($this->path, $pack . 
".key");
 
  117                if(file_exists($keyPath)){
 
  119                        $key = Filesystem::fileGetContents($keyPath);
 
  120                    }
catch(\RuntimeException $e){
 
  123                    $key = rtrim($key, 
"\r\n");
 
  124                    if(strlen($key) !== 32){
 
  127                    $this->encryptionKeys[$index] = $key;
 
  130                $logger->
critical(
"Could not load resource pack \"$pack\": " . $e->getMessage());
 
  134        $logger->
debug(
"Successfully loaded " . count($this->resourcePacks) . 
" resource packs");
 
 
  197        foreach($resourceStack as $pack){
 
  198            $uuid = strtolower($pack->getPackId());
 
  199            if(!Uuid::isValid($uuid)){
 
  202                throw new \InvalidArgumentException(
"Invalid resource pack UUID ($uuid)");
 
  204            if(isset($uuidList[$uuid])){
 
  205                throw new \InvalidArgumentException(
"Cannot load two resource pack with the same UUID ($uuid)");
 
  207            $uuidList[$uuid] = $pack;
 
  208            $resourcePacks[] = $pack;
 
  210        $this->resourcePacks = $resourcePacks;
 
  211        $this->uuidList = $uuidList;
 
 
  241        $id = strtolower($id);
 
  244            unset($this->encryptionKeys[$id]);
 
  245        }elseif(isset($this->uuidList[$id])){
 
  246            if(strlen($key) !== 32){
 
  247                throw new \InvalidArgumentException(
"Encryption key must be exactly 32 bytes long");
 
  249            $this->encryptionKeys[$id] = $key;
 
  251            throw new \InvalidArgumentException(
"Unknown pack ID $id");