Fixed phar plugins not reading resources correctly

This commit is contained in:
Dylan K. Taylor 2018-06-13 12:07:27 +01:00
parent 78eae28a3e
commit c835c97aba
5 changed files with 20 additions and 4 deletions

View File

@ -50,7 +50,7 @@ class PharPluginLoader implements PluginLoader{
* @param string $file
*/
public function loadPlugin(string $file) : void{
$this->loader->addPath("phar://$file/src");
$this->loader->addPath("$file/src");
}
/**
@ -71,4 +71,8 @@ class PharPluginLoader implements PluginLoader{
return null;
}
public function getAccessProtocol() : string{
return "phar://";
}
}

View File

@ -52,4 +52,11 @@ interface PluginLoader{
* @return null|PluginDescription
*/
public function getPluginDescription(string $file) : ?PluginDescription;
/**
* Returns the protocol prefix used to access files in this plugin, e.g. file://, phar://
*
* @return string
*/
public function getAccessProtocol() : string;
}

View File

@ -158,7 +158,8 @@ class PluginManager{
return null;
}
$loader->loadPlugin($path);
$prefixed = $loader->getAccessProtocol() . $path;
$loader->loadPlugin($prefixed);
$mainClass = $description->getMain();
if(!class_exists($mainClass, true)){
@ -175,7 +176,7 @@ class PluginManager{
* @var Plugin $plugin
* @see Plugin::__construct()
*/
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $path);
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed);
$plugin->onLoad();
$this->plugins[$plugin->getDescription()->getName()] = $plugin;

View File

@ -86,4 +86,8 @@ class ScriptPluginLoader implements PluginLoader{
return null;
}
public function getAccessProtocol() : string{
return "file://";
}
}

@ -1 +1 @@
Subproject commit 19fcbf0f9751b4d9d27cdfb007e0fb2bbf3acd04
Subproject commit 1fae225ac376c1a0f4dd57a181dbba591f62944a