Updated PluginAPI with a new way of managing configuration

This commit is contained in:
Shoghi Cervantes Pueyo 2013-01-13 19:33:28 +01:00
parent 4b1f1cfd44
commit 6a97750e06
2 changed files with 13 additions and 9 deletions

View File

@ -109,6 +109,16 @@ class PluginAPI extends stdClass{
return false; return false;
} }
public function configPath(Plugin $plugin){
$p = $this->get($plugin);
if($p === false){
return false;
}
$path = FILE_PATH."plugins/".$p[1]["name"]."/";
$this->plugins[$p[1]["class"]][1]["path"] = $path;
return $path;
}
public function createConfig(Plugin $plugin, $default = array()){ public function createConfig(Plugin $plugin, $default = array()){
$p = $this->get($plugin); $p = $this->get($plugin);
if($p === false){ if($p === false){
@ -116,14 +126,8 @@ class PluginAPI extends stdClass{
} }
$path = FILE_PATH."plugins/".$p[1]["name"]."/"; $path = FILE_PATH."plugins/".$p[1]["name"]."/";
$this->plugins[$p[1]["class"]][1]["path"] = $path; $this->plugins[$p[1]["class"]][1]["path"] = $path;
if(!file_exists($path."config.yml")){ $cnf = new Config($path."config.yml", CONFIG_YAML, $default);
@mkdir($path, 0777); $cnf->save();
$this->writeYAML($path."config.yml", $default);
}else{
$data = $this->readYAML($path."config.yml");
$this->fillDefaults($default, $data);
$this->writeYAML($path."config.yml", $data);
}
return $path; return $path;
} }

View File

@ -86,7 +86,7 @@ class ServerAPI{
"description" => "Server made using PocketMine-MP", "description" => "Server made using PocketMine-MP",
"motd" => "Welcome @username to this server!", "motd" => "Welcome @username to this server!",
"invisible" => false, "invisible" => false,
"port" => 19132 "port" => 19132,
"memory-limit" => "256M", "memory-limit" => "256M",
"last-update" => false, "last-update" => false,
"update-channel" => "stable", "update-channel" => "stable",