Cleaned up plugin property reading

This commit is contained in:
Dylan K. Taylor 2017-09-01 18:32:37 +01:00
parent 506118e28f
commit 517609dc2e

View File

@ -74,11 +74,11 @@ class PluginDescription{
$this->name = str_replace(" ", "_", $this->name);
$this->version = (string) $plugin["version"];
$this->main = $plugin["main"];
$this->api = array_map(function($v){ return (string) $v; }, !is_array($plugin["api"]) ? [$plugin["api"]] : $plugin["api"]);
if(stripos($this->main, "pocketmine\\") === 0){
throw new PluginException("Invalid PluginDescription main, cannot start within the PocketMine namespace");
}
$this->api = array_map("strval", (array) $plugin["api"] ?? []);
$this->compatibleMcpeProtocols = array_map("intval", (array) ($plugin["mcpe-protocol"] ?? []));
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
@ -99,22 +99,17 @@ class PluginDescription{
$this->extensions[$k] = is_array($v) ? $v : [$v];
}
}
if(isset($plugin["softdepend"])){
$this->softDepend = (array) $plugin["softdepend"];
}
if(isset($plugin["loadbefore"])){
$this->loadBefore = (array) $plugin["loadbefore"];
}
if(isset($plugin["website"])){
$this->website = $plugin["website"];
}
if(isset($plugin["description"])){
$this->description = $plugin["description"];
}
if(isset($plugin["prefix"])){
$this->prefix = $plugin["prefix"];
}
$this->softDepend = (array) ($plugin["softdepend"] ?? $this->softDepend);
$this->loadBefore = (array) ($plugin["loadbefore"] ?? $this->loadBefore);
$this->website = (string) ($plugin["website"] ?? $this->website);
$this->description = (string) ($plugin["description"] ?? $this->description);
$this->prefix = (string) ($plugin["prefix"] ?? $this->prefix);
if(isset($plugin["load"])){
$order = strtoupper($plugin["load"]);
if(!defined(PluginLoadOrder::class . "::" . $order)){