mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
PMF Plugin Loading
This commit is contained in:
@@ -59,16 +59,16 @@ class PMF{
|
||||
if($stat["size"] >= 5){ //Header + 2 Bytes
|
||||
return true;
|
||||
}
|
||||
fclose($this->fp);
|
||||
$this->close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function parseInfo(){
|
||||
$this->seek(0);
|
||||
if(fread($this->fp, 3) !== "PMF"){
|
||||
return false;
|
||||
}
|
||||
$this->seek(0);
|
||||
}
|
||||
$this->version = ord($this->read(1));
|
||||
switch($this->version){
|
||||
case 0x01:
|
||||
@@ -87,7 +87,9 @@ class PMF{
|
||||
|
||||
public function close(){
|
||||
unset($this->version, $this->type, $this->file);
|
||||
fclose($this->fp);
|
||||
if(is_object($this->fp)){
|
||||
fclose($this->fp);
|
||||
}
|
||||
}
|
||||
|
||||
public function create($file, $type, $version = PMF_CURRENT_VERSION){
|
||||
@@ -98,7 +100,7 @@ class PMF{
|
||||
}
|
||||
}
|
||||
$this->seek(0);
|
||||
$this->write("PMF" . chr((int) $type) . chr((int) $version));
|
||||
$this->write("PMF" . chr((int) $version) . chr((int) $type));
|
||||
}
|
||||
|
||||
public function read($length){
|
||||
|
@@ -39,8 +39,12 @@ class PMFPlugin extends PMF{
|
||||
$this->parsePlugin();
|
||||
}
|
||||
|
||||
public function getPluginInfo(){
|
||||
return $this->pluginData;
|
||||
}
|
||||
|
||||
protected function parsePlugin(){
|
||||
if($this->type !== 0x01){
|
||||
if($this->getType() !== 0x01){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -48,12 +52,13 @@ class PMFPlugin extends PMF{
|
||||
$this->pluginData["name"] = $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["apiversion"] = 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["extra"] = $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
|
||||
$this->pluginData["code"] = "";
|
||||
while(!feof($this->fp)){
|
||||
$this->pluginData["code"] .= fread($this->fp, 4096);
|
||||
$this->pluginData["code"] .= $this->read(4096);
|
||||
}
|
||||
$this->pluginData["code"] = gzinflate($this->pluginData["code"]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user