mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Faster plugin filter loading
This commit is contained in:
parent
7e9304a0c9
commit
5865f17c75
@ -954,8 +954,8 @@ class Server{
|
|||||||
$this->commandMap = new SimpleCommandMap($this);
|
$this->commandMap = new SimpleCommandMap($this);
|
||||||
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
||||||
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
||||||
$this->pluginManager->registerInterface("pocketmine\\plugin\\FolderPluginLoader");
|
|
||||||
$this->pluginManager->registerInterface("pocketmine\\plugin\\PharPluginLoader");
|
$this->pluginManager->registerInterface("pocketmine\\plugin\\PharPluginLoader");
|
||||||
|
$this->pluginManager->registerInterface("pocketmine\\plugin\\FolderPluginLoader");
|
||||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||||
|
|
||||||
//TODO: update checking (async)
|
//TODO: update checking (async)
|
||||||
|
@ -171,13 +171,12 @@ class PluginManager{
|
|||||||
$loadedPlugins = array();
|
$loadedPlugins = array();
|
||||||
$dependencies = array();
|
$dependencies = array();
|
||||||
$softDependencies = array();
|
$softDependencies = array();
|
||||||
foreach(new \IteratorIterator(new \DirectoryIterator($directory)) as $file){
|
foreach($this->fileAssociations as $loader){
|
||||||
|
foreach(new \RegexIterator(new \DirectoryIterator($directory), $loader->getPluginFilters()) as $file){
|
||||||
if($file === "." or $file === ".."){
|
if($file === "." or $file === ".."){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$file = $directory . $file;
|
$file = $directory . $file;
|
||||||
foreach($this->fileAssociations as $loader){
|
|
||||||
if(preg_match($loader->getPluginFilters(), basename($file)) > 0){
|
|
||||||
$description = $loader->getPluginDescription($file);
|
$description = $loader->getPluginDescription($file);
|
||||||
if($description instanceof PluginDescription){
|
if($description instanceof PluginDescription){
|
||||||
$name = $description->getName();
|
$name = $description->getName();
|
||||||
@ -193,18 +192,15 @@ class PluginManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$compatible = false;
|
$compatible = false;
|
||||||
|
|
||||||
//Check multiple dependencies
|
//Check multiple dependencies
|
||||||
foreach($description->getCompatibleApis() as $version){
|
foreach($description->getCompatibleApis() as $version){
|
||||||
//Format: majorVersion.minorVersion.patch
|
//Format: majorVersion.minorVersion.patch
|
||||||
$version = array_map("intval", explode(".", $version));
|
$version = array_map("intval", explode(".", $version));
|
||||||
$apiVersion = array_map("intval", explode(".", $this->server->getApiVersion()));
|
$apiVersion = array_map("intval", explode(".", $this->server->getApiVersion()));
|
||||||
|
|
||||||
//Completely different API version
|
//Completely different API version
|
||||||
if($version[0] !== $apiVersion[0]){
|
if($version[0] !== $apiVersion[0]){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If the plugin requires new API features, being backwards compatible
|
//If the plugin requires new API features, being backwards compatible
|
||||||
if($version[1] > $apiVersion[1]){
|
if($version[1] > $apiVersion[1]){
|
||||||
continue;
|
continue;
|
||||||
@ -231,12 +227,10 @@ class PluginManager{
|
|||||||
$softDependencies[$before] = array($name);
|
$softDependencies[$before] = array($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(count($plugins) > 0){
|
while(count($plugins) > 0){
|
||||||
$missingDependency = true;
|
$missingDependency = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user