mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
plugins can require other plugins now
This commit is contained in:
parent
48903689dd
commit
dfc96b7a20
1 changed files with 33 additions and 0 deletions
|
|
@ -239,12 +239,45 @@ class PluginAPI extends stdClass{
|
||||||
|
|
||||||
public function initAll(){
|
public function initAll(){
|
||||||
console("[INFO] Starting plugins...");
|
console("[INFO] Starting plugins...");
|
||||||
|
$names = array();
|
||||||
|
$versions = array();
|
||||||
foreach($this->plugins as $p){
|
foreach($this->plugins as $p){
|
||||||
|
$names[] = $p[1]["name"];
|
||||||
|
$versions[] = $p[1]["version"];
|
||||||
|
}
|
||||||
|
foreach($this->plugins as $p){
|
||||||
|
if($p[0] instanceof OtherPluginRequirement){
|
||||||
|
foreach($p[0]->getRequiredPlugins() as $required){
|
||||||
|
if(in_array($required->pluginName, $names)){
|
||||||
|
console("hm");
|
||||||
|
if(!in_array($required->version, $versions) && $required->version !== false){
|
||||||
|
console("hm2");
|
||||||
|
console("[WARNING] Plugin \"".$required->pluginName."\" needed by \"".$p[1]["name"]."\" is incorrect version.");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
console("[ERROR] Plugin \"".$required->pluginName."\" needed by \"".$p[1]["name"]."\" is not found.");
|
||||||
|
ServerAPI::request()->close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$p[0]->init(); //ARGHHH!!! Plugin loading randomly fails!!
|
$p[0]->init(); //ARGHHH!!! Plugin loading randomly fails!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RequiredPluginEntry{ //Use this as object of requirements array
|
||||||
|
public $pluginName;
|
||||||
|
public $version;
|
||||||
|
public function __construct($name, $version = false){
|
||||||
|
$this->pluginName = $name;
|
||||||
|
$this->version = $version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OtherPluginRequirement{
|
||||||
|
public function getRequiredPlugins();
|
||||||
|
}
|
||||||
|
|
||||||
interface Plugin{
|
interface Plugin{
|
||||||
public function __construct(ServerAPI $api, $server = false);
|
public function __construct(ServerAPI $api, $server = false);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue