GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
FolderPluginLoader Class Reference

Public Member Functions

 __construct (Server $server)
 
 loadPlugin ($file)
 
 getPluginDescription ($file)
 
 getPluginFilters ()
 
 enablePlugin (Plugin $plugin)
 
 disablePlugin (Plugin $plugin)
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Server  $server)
Parameters
Server$server
50  {
51  $this->server = $server;
52  }

Member Function Documentation

◆ disablePlugin()

disablePlugin ( Plugin  $plugin)
Parameters
Plugin$plugin

Implements PluginLoader.

146  {
147  if($plugin instanceof PluginBase and $plugin->isEnabled()){
148  MainLogger::getLogger()->info("Disabling " . $plugin->getDescription()->getFullName());
149 
150  Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
151 
152  $plugin->setEnabled(false);
153  }
154  }

◆ enablePlugin()

enablePlugin ( Plugin  $plugin)
Parameters
Plugin$plugin

Implements PluginLoader.

133  {
134  if($plugin instanceof PluginBase and !$plugin->isEnabled()){
135  MainLogger::getLogger()->info("Enabling " . $plugin->getDescription()->getFullName());
136 
137  $plugin->setEnabled(true);
138 
139  Server::getInstance()->getPluginManager()->callEvent(new PluginEnableEvent($plugin));
140  }
141  }

◆ getPluginDescription()

getPluginDescription (   $file)

Gets the PluginDescription from the file

Parameters
string$file
Returns
PluginDescription

Implements PluginLoader.

99  {
100  if(is_dir($file) and file_exists($file . "/plugin.yml")){
101  $yaml = @file_get_contents($file . "/plugin.yml");
102  if($yaml != ""){
103  return new PluginDescription($yaml);
104  }
105  }
106 
107  return null;
108  }

◆ getPluginFilters()

getPluginFilters ( )

Returns the filename patterns that this loader accepts

Returns
array|string

Implements PluginLoader.

115  {
116  return "/[^\\.]/";
117  }

◆ loadPlugin()

loadPlugin (   $file)

Loads the plugin contained in $file

Parameters
string$file
Returns
Plugin

Implements PluginLoader.

61  {
62  if(is_dir($file) and file_exists($file . "/plugin.yml") and file_exists($file . "/src/")){
63  if(($description = $this->getPluginDescription($file)) instanceof PluginDescription){
64  MainLogger::getLogger()->info(TextFormat::LIGHT_PURPLE . "Loading (Source) " . $description->getFullName());
65  $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName();
66  if(file_exists($dataFolder) and !is_dir($dataFolder)){
67  trigger_error("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory", E_USER_WARNING);
68 
69  return null;
70  }
71 
72 
73  $className = $description->getMain();
74  $this->server->getLoader()->addPath($file . "/src");
75 
76  if(class_exists($className, true)){
77  $plugin = new $className();
78  $this->initPlugin($plugin, $description, $dataFolder, $file);
79 
80  return $plugin;
81  }else{
82  trigger_error("Couldn't load source plugin " . $description->getName() . ": main class not found", E_USER_WARNING);
83 
84  return null;
85  }
86  }
87  }
88 
89  return null;
90  }

The documentation for this class was generated from the following file: