ResourcePackManager: avoid repeated operation

This commit is contained in:
Dylan K. Taylor 2022-09-28 20:57:17 +01:00
parent bda0ca23b4
commit d6bbf8217d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -113,12 +113,13 @@ class ResourcePackManager{
if($newPack instanceof ResourcePack){ if($newPack instanceof ResourcePack){
$this->resourcePacks[] = $newPack; $this->resourcePacks[] = $newPack;
$this->uuidList[strtolower($newPack->getPackId())] = $newPack; $index = strtolower($newPack->getPackId());
$this->uuidList[$index] = $newPack;
$keyPath = Path::join($this->path, $pack . ".key"); $keyPath = Path::join($this->path, $pack . ".key");
if(file_exists($keyPath)){ if(file_exists($keyPath)){
try{ try{
$this->encryptionKeys[strtolower($newPack->getPackId())] = ErrorToExceptionHandler::trapAndRemoveFalse( $this->encryptionKeys[$index] = ErrorToExceptionHandler::trapAndRemoveFalse(
fn() => file_get_contents($keyPath) fn() => file_get_contents($keyPath)
); );
}catch(\ErrorException $e){ }catch(\ErrorException $e){