mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Start using webmozart/pathutil for joining paths (#4287)
This commit is contained in:
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\resourcepacks;
|
||||
|
||||
use pocketmine\utils\Config;
|
||||
use Webmozart\PathUtil\Path;
|
||||
use function array_keys;
|
||||
use function copy;
|
||||
use function count;
|
||||
@ -63,11 +64,12 @@ class ResourcePackManager{
|
||||
throw new \InvalidArgumentException("Resource packs path $path exists and is not a directory");
|
||||
}
|
||||
|
||||
if(!file_exists($this->path . "resource_packs.yml")){
|
||||
copy(\pocketmine\RESOURCE_PATH . "resource_packs.yml", $this->path . "resource_packs.yml");
|
||||
$resourcePacksYml = Path::join($this->path, "resource_packs.yml");
|
||||
if(!file_exists($resourcePacksYml)){
|
||||
copy(Path::join(\pocketmine\RESOURCE_PATH, "resource_packs.yml"), $resourcePacksYml);
|
||||
}
|
||||
|
||||
$resourcePacksConfig = new Config($this->path . "resource_packs.yml", Config::YAML, []);
|
||||
$resourcePacksConfig = new Config($resourcePacksYml, Config::YAML, []);
|
||||
|
||||
$this->serverForceResources = (bool) $resourcePacksConfig->get("force_resources", false);
|
||||
|
||||
@ -84,7 +86,7 @@ class ResourcePackManager{
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
$packPath = $this->path . DIRECTORY_SEPARATOR . $pack;
|
||||
$packPath = Path::join($this->path, $pack);
|
||||
if(!file_exists($packPath)){
|
||||
throw new ResourcePackException("File or directory not found");
|
||||
}
|
||||
@ -120,7 +122,7 @@ class ResourcePackManager{
|
||||
* Returns the directory which resource packs are loaded from.
|
||||
*/
|
||||
public function getPath() : string{
|
||||
return $this->path;
|
||||
return $this->path . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user