35
35
use pocketmine \plugin \Plugin ;
36
36
use pocketmine \plugin \PluginBase ;
37
37
use pocketmine \Server ;
38
- use pocketmine \utils \AssumptionFailedError ;
39
38
use pocketmine \utils \TextFormat ;
40
39
use pocketmine \utils \Utils ;
41
40
use function assert ;
45
44
use function generatePluginMetadataFromYml ;
46
45
use function implode ;
47
46
use function ini_get ;
47
+ use function is_dir ;
48
48
use function ksort ;
49
49
use function php_ini_loaded_file ;
50
50
use function realpath ;
@@ -75,7 +75,6 @@ public function onLoad() : void{
75
75
$ map ->register ("devtools " , new ExtractPluginCommand ($ this ));
76
76
$ map ->register ("devtools " , new GeneratePluginCommand ($ this ));
77
77
78
- $ this ->getServer ()->getPluginManager ()->registerInterface (new FolderPluginLoader ($ this ->getServer ()->getLoader ()));
79
78
$ this ->getLogger ()->info ("Registered folder plugin loader " );
80
79
}
81
80
@@ -87,7 +86,7 @@ public function onCommand(CommandSender $sender, Command $command, string $label
87
86
$ succeeded = $ failed = [];
88
87
$ skipped = 0 ;
89
88
foreach ($ plugins as $ plugin ){
90
- if (!$ plugin-> getPluginLoader () instanceof FolderPluginLoader ){
89
+ if (!self :: isFolderPlugin ( $ plugin) ){
91
90
$ skipped ++;
92
91
continue ;
93
92
}
@@ -254,17 +253,14 @@ private function makePluginCommand(CommandSender $sender, array $args) : bool{
254
253
}
255
254
$ description = $ plugin ->getDescription ();
256
255
257
- if (!($ plugin-> getPluginLoader () instanceof FolderPluginLoader )){
256
+ if (!self :: isFolderPlugin ($ plugin )){
258
257
$ sender ->sendMessage (TextFormat::RED . "Plugin " . $ description ->getName () . " is not in folder structure. " );
259
258
return false ;
260
259
}
261
260
262
261
$ pharPath = $ this ->getDataFolder () . $ description ->getName () . "_v " . $ description ->getVersion () . ".phar " ;
263
262
264
- $ reflection = new \ReflectionClass (PluginBase::class);
265
- $ file = $ reflection ->getProperty ("file " );
266
- $ file ->setAccessible (true );
267
- $ pfile = rtrim ($ file ->getValue ($ plugin ), '/ ' );
263
+ $ pfile = rtrim ($ plugin ->getFile (), '/ ' );
268
264
$ filePath = realpath ($ pfile );
269
265
if ($ filePath === false ){
270
266
$ sender ->sendMessage (TextFormat::RED . "Plugin " . $ description ->getName () . " not found at $ pfile (maybe deleted?) " );
@@ -406,4 +402,9 @@ private function handlerListByPluginCommand(CommandSender $sender, array $args)
406
402
407
403
return true ;
408
404
}
405
+
406
+ private static function isFolderPlugin (Plugin $ plugin ) : bool {
407
+ $ realPath = realpath ($ plugin ->getFile ());
408
+ return $ realPath !== false && is_dir ($ realPath );
409
+ }
409
410
}
0 commit comments