mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 18:29:46 +00:00
PluginLoader: rename parameters
This commit is contained in:
parent
e0ad39b70a
commit
cb251069dd
@ -41,19 +41,19 @@ class FolderPluginLoader implements PluginLoader{
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void{
|
||||
$description = $this->getPluginDescription($file);
|
||||
public function loadPlugin(string $path) : void{
|
||||
$description = $this->getPluginDescription($path);
|
||||
if($description !== null){
|
||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
|
||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
||||
$pluginYmlPath = Path::join($file, "plugin.yml");
|
||||
if(is_dir($file) && file_exists($pluginYmlPath)){
|
||||
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||
$pluginYmlPath = Path::join($path, "plugin.yml");
|
||||
if(is_dir($path) && file_exists($pluginYmlPath)){
|
||||
try{
|
||||
$yaml = Filesystem::fileGetContents($pluginYmlPath);
|
||||
}catch(\RuntimeException){
|
||||
|
@ -42,18 +42,18 @@ class PharPluginLoader implements PluginLoader{
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void{
|
||||
$description = $this->getPluginDescription($file);
|
||||
public function loadPlugin(string $path) : void{
|
||||
$description = $this->getPluginDescription($path);
|
||||
if($description !== null){
|
||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
|
||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
||||
$phar = new \Phar($file);
|
||||
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||
$phar = new \Phar($path);
|
||||
if(isset($phar["plugin.yml"])){
|
||||
return new PluginDescription($phar["plugin.yml"]->getContent());
|
||||
}
|
||||
|
@ -36,13 +36,13 @@ interface PluginLoader{
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void;
|
||||
public function loadPlugin(string $path) : void;
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
* @throws PluginDescriptionParseException
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription;
|
||||
public function getPluginDescription(string $path) : ?PluginDescription;
|
||||
|
||||
/**
|
||||
* Returns the protocol prefix used to access files in this plugin, e.g. file://, phar://
|
||||
|
@ -46,15 +46,15 @@ class ScriptPluginLoader implements PluginLoader{
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void{
|
||||
include_once $file;
|
||||
public function loadPlugin(string $path) : void{
|
||||
include_once $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
||||
$content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||
$content = @file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if($content === false){
|
||||
return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user