Simple script loader, not for plugin development For an example see https://gist.github.com/shoghicp/516105d470cf7d140757
◆ __construct()
- Parameters
-
41 $this->server = $server;
◆ disablePlugin()
disablePlugin |
( |
Plugin |
$plugin | ) |
|
- Parameters
-
Implements PluginLoader.
155 if($plugin instanceof PluginBase and $plugin->isEnabled()){
156 $this->server->getLogger()->info($this->server->getLanguage()->translateString(
"pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
158 $this->server->getPluginManager()->callEvent(
new PluginDisableEvent($plugin));
160 $plugin->setEnabled(
false);
◆ enablePlugin()
enablePlugin |
( |
Plugin |
$plugin | ) |
|
- Parameters
-
Implements PluginLoader.
142 if($plugin instanceof PluginBase and !$plugin->isEnabled()){
143 $this->server->getLogger()->info($this->server->getLanguage()->translateString(
"pocketmine.plugin.enable", [$plugin->getDescription()->getFullName()]));
145 $plugin->setEnabled(
true);
147 $this->server->getPluginManager()->callEvent(
new PluginEnableEvent($plugin));
◆ getPluginDescription()
getPluginDescription |
( |
|
$file | ) |
|
Gets the PluginDescription from the file
- Parameters
-
- Returns
- PluginDescription
Implements PluginLoader.
86 $content = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
90 $insideHeader =
false;
91 foreach($content as $line){
92 if(!$insideHeader and strpos($line,
"/**") !==
false){
96 if(preg_match(
"/^[ \t]+\\*[ \t]+@([a-zA-Z]+)([ \t]+(.*))?$/", $line, $matches) > 0){
98 $content = trim($matches[3] ??
"");
100 if($key ===
"notscript"){
104 $data[$key] = $content;
107 if($insideHeader and strpos($line,
"**/") !==
false){
112 return new PluginDescription($data);
◆ getPluginFilters()
Returns the filename patterns that this loader accepts
- Returns
- string
Implements PluginLoader.
◆ loadPlugin()
Loads the plugin contained in $file
- Parameters
-
- Returns
- Plugin
- Exceptions
-
Implements PluginLoader.
55 $this->server->getLogger()->info($this->server->getLanguage()->translateString(
"pocketmine.plugin.load", [$description->getFullName()]));
56 $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName();
57 if(file_exists($dataFolder) and !is_dir($dataFolder)){
58 throw new \InvalidStateException(
"Projected dataFolder '" . $dataFolder .
"' for " . $description->getName() .
" exists and is not a directory");
63 $className = $description->getMain();
65 if(class_exists($className,
true)){
66 $plugin =
new $className();
67 $this->initPlugin($plugin, $description, $dataFolder, $file);
71 throw new PluginException(
"Couldn't load plugin " . $description->getName() .
": main class not found");
The documentation for this class was generated from the following file:
- src/pocketmine/plugin/ScriptPluginLoader.php