mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 08:35:20 +00:00
Fixed plugin loaders trying to load plugins they aren't able to load
closes #2125 This is an API break for things implementing the PluginLoader interface.
This commit is contained in:
@ -101,6 +101,11 @@ class PharPluginLoader implements PluginLoader{
|
||||
return "/\\.phar$/i";
|
||||
}
|
||||
|
||||
public function canLoadPlugin(string $path) : bool{
|
||||
$ext = ".phar";
|
||||
return is_file($path) and substr($path, -strlen($ext)) === $ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PluginBase $plugin
|
||||
* @param PluginDescription $description
|
||||
|
@ -53,6 +53,15 @@ interface PluginLoader{
|
||||
*/
|
||||
public function getPluginFilters() : string;
|
||||
|
||||
/**
|
||||
* Returns whether this PluginLoader can load the plugin in the given path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canLoadPlugin(string $path) : bool;
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
*
|
||||
|
@ -210,6 +210,9 @@ class PluginManager{
|
||||
continue;
|
||||
}
|
||||
$file = $directory . $file;
|
||||
if(!$loader->canLoadPlugin($file)){
|
||||
continue;
|
||||
}
|
||||
try{
|
||||
$description = $loader->getPluginDescription($file);
|
||||
if($description instanceof PluginDescription){
|
||||
|
@ -124,6 +124,11 @@ class ScriptPluginLoader implements PluginLoader{
|
||||
return "/\\.php$/i";
|
||||
}
|
||||
|
||||
public function canLoadPlugin(string $path) : bool{
|
||||
$ext = ".php";
|
||||
return is_file($path) and substr($path, -strlen($ext)) === $ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PluginBase $plugin
|
||||
* @param PluginDescription $description
|
||||
|
Submodule tests/plugins/PocketMine-DevTools updated: 96fa93a3b4...a897b84de4
Reference in New Issue
Block a user