PocketMine-MP 5.23.2 git-45917d495c14f3ce37bbf0848262ad8a470030f3
Loading...
Searching...
No Matches
ScriptPluginLoader.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\plugin;
25
27use function count;
28use function file;
29use function implode;
30use function is_file;
31use function str_contains;
32use function str_ends_with;
33use const FILE_IGNORE_NEW_LINES;
34use const FILE_SKIP_EMPTY_LINES;
35
41
42 public function canLoadPlugin(string $path) : bool{
43 return is_file($path) && str_ends_with($path, ".php");
44 }
45
49 public function loadPlugin(string $file) : void{
50 include_once $file;
51 }
52
56 public function getPluginDescription(string $file) : ?PluginDescription{
57 $content = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
58 if($content === false){
59 return null;
60 }
61
62 $insideHeader = false;
63
64 $docCommentLines = [];
65 foreach($content as $line){
66 if(!$insideHeader){
67 if(str_contains($line, "/**")){
68 $insideHeader = true;
69 }else{
70 continue;
71 }
72 }
73
74 $docCommentLines[] = $line;
75
76 if(str_contains($line, "*/")){
77 break;
78 }
79 }
80
81 $data = Utils::parseDocComment(implode("\n", $docCommentLines));
82 if(count($data) !== 0){
83 return new PluginDescription($data);
84 }
85
86 return null;
87 }
88
89 public function getAccessProtocol() : string{
90 return "";
91 }
92}