mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
ResourcePackManager: added setResourceStack()
this enables plugins to modify the resource pack stack however they see fit. Modifying the existing stack can be done by doing array modifications on the result of getResourceStack() and then setting it back again using this method.
This commit is contained in:
parent
50b70708fb
commit
880d01daea
@ -158,6 +158,29 @@ class ResourcePackManager{
|
||||
return $this->resourcePacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the resource packs to use. Packs earliest in the list will appear at the top of the stack (maximum
|
||||
* priority), and later ones will appear below (lower priority), in the same manner as the Bedrock resource packs
|
||||
* screen in-game.
|
||||
*
|
||||
* @param ResourcePack[] $resourceStack
|
||||
* @phpstan-param list<ResourcePack> $resourceStack
|
||||
*/
|
||||
public function setResourceStack(array $resourceStack) : void{
|
||||
$uuidList = [];
|
||||
$resourcePacks = [];
|
||||
foreach($resourceStack as $pack){
|
||||
$uuid = strtolower($pack->getPackId());
|
||||
if(isset($uuidList[$uuid])){
|
||||
throw new \InvalidArgumentException("Cannot load two resource pack with the same UUID ($uuid)");
|
||||
}
|
||||
$uuidList[$uuid] = $pack;
|
||||
$resourcePacks[] = $pack;
|
||||
}
|
||||
$this->resourcePacks = $resourcePacks;
|
||||
$this->uuidList = $uuidList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource pack matching the specified UUID string, or null if the ID was not recognized.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user