mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 15:19:56 +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
|
* Loads the plugin contained in $file
|
||||||
*/
|
*/
|
||||||
public function loadPlugin(string $file) : void{
|
public function loadPlugin(string $path) : void{
|
||||||
$description = $this->getPluginDescription($file);
|
$description = $this->getPluginDescription($path);
|
||||||
if($description !== null){
|
if($description !== null){
|
||||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
|
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the PluginDescription from the file
|
* Gets the PluginDescription from the file
|
||||||
*/
|
*/
|
||||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||||
$pluginYmlPath = Path::join($file, "plugin.yml");
|
$pluginYmlPath = Path::join($path, "plugin.yml");
|
||||||
if(is_dir($file) && file_exists($pluginYmlPath)){
|
if(is_dir($path) && file_exists($pluginYmlPath)){
|
||||||
try{
|
try{
|
||||||
$yaml = Filesystem::fileGetContents($pluginYmlPath);
|
$yaml = Filesystem::fileGetContents($pluginYmlPath);
|
||||||
}catch(\RuntimeException){
|
}catch(\RuntimeException){
|
||||||
|
@ -42,18 +42,18 @@ class PharPluginLoader implements PluginLoader{
|
|||||||
/**
|
/**
|
||||||
* Loads the plugin contained in $file
|
* Loads the plugin contained in $file
|
||||||
*/
|
*/
|
||||||
public function loadPlugin(string $file) : void{
|
public function loadPlugin(string $path) : void{
|
||||||
$description = $this->getPluginDescription($file);
|
$description = $this->getPluginDescription($path);
|
||||||
if($description !== null){
|
if($description !== null){
|
||||||
$this->loader->addPath($description->getSrcNamespacePrefix(), "$file/src");
|
$this->loader->addPath($description->getSrcNamespacePrefix(), "$path/src");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the PluginDescription from the file
|
* Gets the PluginDescription from the file
|
||||||
*/
|
*/
|
||||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||||
$phar = new \Phar($file);
|
$phar = new \Phar($path);
|
||||||
if(isset($phar["plugin.yml"])){
|
if(isset($phar["plugin.yml"])){
|
||||||
return new PluginDescription($phar["plugin.yml"]->getContent());
|
return new PluginDescription($phar["plugin.yml"]->getContent());
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ interface PluginLoader{
|
|||||||
/**
|
/**
|
||||||
* Loads the plugin contained in $file
|
* Loads the plugin contained in $file
|
||||||
*/
|
*/
|
||||||
public function loadPlugin(string $file) : void;
|
public function loadPlugin(string $path) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the PluginDescription from the file
|
* Gets the PluginDescription from the file
|
||||||
* @throws PluginDescriptionParseException
|
* @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://
|
* 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
|
* Loads the plugin contained in $file
|
||||||
*/
|
*/
|
||||||
public function loadPlugin(string $file) : void{
|
public function loadPlugin(string $path) : void{
|
||||||
include_once $file;
|
include_once $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the PluginDescription from the file
|
* Gets the PluginDescription from the file
|
||||||
*/
|
*/
|
||||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
public function getPluginDescription(string $path) : ?PluginDescription{
|
||||||
$content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
$content = @file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
if($content === false){
|
if($content === false){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user