mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
New Plugin format includes multiple API versions
This commit is contained in:
parent
012ecbe40a
commit
2861fe0703
@ -85,7 +85,7 @@ class PluginAPI extends stdClass{
|
|||||||
console("[ERROR] [PluginAPI] Failed parsing of ".basename($file));
|
console("[ERROR] [PluginAPI] Failed parsing of ".basename($file));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
console("[INFO] [PluginAPI] Loading plugin \"\x1b[32m".$info["name"]."\x1b[0m\" \x1b[35m".$info["version"]." #".intval($info["apiversion"])."\x1b[0m by \x1b[36m".$info["author"]."\x1b[0m");
|
console("[INFO] [PluginAPI] Loading plugin \"\x1b[32m".$info["name"]."\x1b[0m\" \x1b[35m".$info["version"]." \x1b[0m by \x1b[36m".$info["author"]."\x1b[0m");
|
||||||
if(class_exists($info["class"])){
|
if(class_exists($info["class"])){
|
||||||
console("[ERROR] [PluginAPI] Failed loading plugin: class exists");
|
console("[ERROR] [PluginAPI] Failed loading plugin: class exists");
|
||||||
return false;
|
return false;
|
||||||
@ -96,11 +96,11 @@ class PluginAPI extends stdClass{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$className = $info["class"];
|
$className = $info["class"];
|
||||||
if(isset($info["apiversion"]) and intval($info["apiversion"]) > CURRENT_API_VERSION){
|
$apiversion = array_map("intval", explode(",", (string) $info["apiversion"]));
|
||||||
console("[ERROR] [PluginAPI] Plugin \"".$info["name"]."\" uses a newer API! It can crash or corrupt the server!");
|
if(!in_array((string) CURRENT_API_VERSION, $apiversion)){
|
||||||
}elseif(!isset($info["apiversion"]) or intval($info["apiversion"]) < CURRENT_API_VERSION){
|
console("[ERROR] [PluginAPI] Plugin \"".$info["name"]."\" is not compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!");
|
||||||
console("[DEBUG] [PluginAPI] Plugin \"".$info["name"]."\" uses an old API", true, true, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$object = new $className($this->server->api, false);
|
$object = new $className($this->server->api, false);
|
||||||
if(!($object instanceof Plugin)){
|
if(!($object instanceof Plugin)){
|
||||||
console("[ERROR] [PluginAPI] Plugin \"\x1b[36m".$info["name"]."\x1b[0m\" doesn't use the Plugin Interface");
|
console("[ERROR] [PluginAPI] Plugin \"\x1b[36m".$info["name"]."\x1b[0m\" doesn't use the Plugin Interface");
|
||||||
|
@ -29,7 +29,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
require_once(FILE_PATH."/src/pmf/PMF.php");
|
require_once(FILE_PATH."/src/pmf/PMF.php");
|
||||||
/***REM_END***/
|
/***REM_END***/
|
||||||
|
|
||||||
define("PMF_CURRENT_PLUGIN_VERSION", 0x00);
|
define("PMF_CURRENT_PLUGIN_VERSION", 0x01);
|
||||||
|
|
||||||
class PMFPlugin extends PMF{
|
class PMFPlugin extends PMF{
|
||||||
private $pluginData = array();
|
private $pluginData = array();
|
||||||
@ -52,7 +52,11 @@ class PMFPlugin extends PMF{
|
|||||||
$this->pluginData["name"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->pluginData["name"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
$this->pluginData["version"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->pluginData["version"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
$this->pluginData["author"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->pluginData["author"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
|
if($this->pluginData["fversion"] >= 0x01){
|
||||||
|
$this->pluginData["apiversion"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
|
}else{
|
||||||
$this->pluginData["apiversion"] = Utils::readShort($this->read(2), false);
|
$this->pluginData["apiversion"] = Utils::readShort($this->read(2), false);
|
||||||
|
}
|
||||||
$this->pluginData["class"] = $this->read(Utils::readShort($this->read(2), false));
|
$this->pluginData["class"] = $this->read(Utils::readShort($this->read(2), false));
|
||||||
$this->pluginData["identifier"] = $this->read(Utils::readShort($this->read(2), false)); //Will be used to check for updates
|
$this->pluginData["identifier"] = $this->read(Utils::readShort($this->read(2), false)); //Will be used to check for updates
|
||||||
$this->pluginData["extra"] = gzinflate($this->read(Utils::readShort($this->read(2), false))); //Additional custom plugin data
|
$this->pluginData["extra"] = gzinflate($this->read(Utils::readShort($this->read(2), false))); //Additional custom plugin data
|
||||||
|
Loading…
x
Reference in New Issue
Block a user