Drop PluginLoader from Plugin, expose path instead

we already had this anyway, and it's already being reflected into.
Instead of DevTools checking for FolderPluginLoader instances, it
could just check if the file is a directory instead.
This commit is contained in:
Dylan K. Taylor 2025-05-04 16:41:40 +01:00
parent 3de604ef95
commit 2a42e2c75d
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 5 additions and 12 deletions

View File

@ -259,10 +259,8 @@ class CrashDump{
}
if(file_exists($filePath)){
$reflection = new \ReflectionClass(PluginBase::class);
$file = $reflection->getProperty("file");
foreach($this->server->getPluginManager()->getPlugins() as $plugin){
$filePath = Filesystem::cleanPath($file->getValue($plugin));
$filePath = Filesystem::cleanPath($plugin->getFile());
if(str_starts_with($frameCleanPath, $filePath)){
$this->data->plugin = $plugin->getName();
break;

View File

@ -34,7 +34,7 @@ use pocketmine\Server;
*/
interface Plugin{
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, string $resourceFolder);
public function __construct(Server $server, PluginDescription $description, string $dataFolder, string $file, string $resourceFolder);
public function isEnabled() : bool;
@ -59,7 +59,7 @@ interface Plugin{
public function getLogger() : \AttachableLogger;
public function getPluginLoader() : PluginLoader;
public function getFile() : string;
public function getScheduler() : TaskScheduler;

View File

@ -59,7 +59,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
private TaskScheduler $scheduler;
public function __construct(
private PluginLoader $loader,
private Server $server,
private PluginDescription $description,
private string $dataFolder,
@ -311,14 +310,10 @@ abstract class PluginBase implements Plugin, CommandExecutor{
return $this->description->getFullName();
}
protected function getFile() : string{
public function getFile() : string{
return $this->file;
}
public function getPluginLoader() : PluginLoader{
return $this->loader;
}
public function getScheduler() : TaskScheduler{
return $this->scheduler;
}

View File

@ -220,7 +220,7 @@ class PluginManager{
* @var Plugin $plugin
* @see Plugin::__construct()
*/
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed, $prefixed . "/resources/");
$plugin = new $mainClass($this->server, $description, $dataFolder, $prefixed, $prefixed . "/resources/");
$this->plugins[$plugin->getDescription()->getName()] = $plugin;
return $plugin;