Update channels!

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-26 20:25:39 +01:00
parent 356c5a6a72
commit c8a0315c52
5 changed files with 42 additions and 16 deletions

View File

@ -47,6 +47,7 @@ Current features of the server:
* Full Creative mode!
* Plugin API
* Custom world generation
* Update Channels!! (stable / dev)
How to contact me

View File

@ -17,7 +17,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles
### Alpha v1.1
## Beta (Survival)
- Random Chunk Updates
- Mob spawning, item pick up

View File

@ -95,22 +95,47 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
console("[INFO] Checking for new server version");
console("[INFO] Last check: ".date("Y-m-d H:i:s", $this->getProperty("last-update")));
$info = json_decode(Utils::curl_get("https://api.github.com/repos/shoghicp/PocketMine-MP"), true);
if($info === false or !isset($info["updated_at"])){
console("[ERROR] GitHub API Error");
}else{
$last = new DateTime($info["updated_at"]);
$last = $last->getTimestamp();
if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false){
console("[NOTICE] PocketMine-MP has been updated at ".date("Y-m-d H:i:s", $last));
console("[NOTICE] If you want to update, get the latest version at https://github.com/shoghicp/PocketMine-MP/archive/master.zip");
console("[NOTICE] This message will dissapear when you issue the command \"/update-done\"");
sleep(3);
$channel = "stable";
if($this->getProperty("update-channel") == "dev" or $this->getProperty("update-channel") == "development"){
$channel = "dev";
}
if($channel === "dev"){
$info = json_decode(Utils::curl_get("https://api.github.com/repos/shoghicp/PocketMine-MP"), true);
if($info === false or !isset($info["updated_at"])){
console("[ERROR] GitHub API Error");
}else{
$last = time();
$this->setProperty("last-update", $last);
console("[INFO] This is the latest version");
$last = new DateTime($info["updated_at"]);
$last = $last->getTimestamp();
if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false){
console("[NOTICE] A new DEVELOPMENT version of PocketMine-MP has been released");
console("[NOTICE] If you want to update, get the latest version at https://github.com/shoghicp/PocketMine-MP/archive/master.zip");
console("[NOTICE] This message will dissapear when you issue the command \"/update-done\"");
sleep(3);
}else{
$this->setProperty("last-update", time());
console("[INFO] This is the latest DEVELOPMENT version");
}
}
}else{
$info = json_decode(Utils::curl_get("https://api.github.com/repos/shoghicp/PocketMine-MP/tags"), true);
if($info === false or !isset($info[0])){
console("[ERROR] GitHub API Error");
}else{
$info = $info[0];
var_dump($info);
if($info["name"] != MAJOR_VERSION){
console("[NOTICE] A new STABLE version of PocketMine-MP has been released");
console("[NOTICE] Version \"".$info["name"]."\" [".substr($info["commit"]["sha"], 0, 10)."]");
console("[NOTICE] Download it at ".$info["zipball_url"]);
console("[NOTICE] This message will dissapear as soon as you update\"");
sleep(5);
}else{
$this->setProperty("last-update", time());
console("[INFO] This is the latest STABLE version");
}
}
}
}
if(file_exists(FILE_PATH."data/maps/level.dat")){

View File

@ -40,4 +40,4 @@ define("CURRENT_VERSION", 1);
define("LOG", true);
define("MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78");
define("TEST_MD5", "5ca8eced50a5801619f7ae86d631a4e7");
define("MAJOR_VERSION", "Alpha v1.0");
define("MAJOR_VERSION", "Alpha_1.0");

View File

@ -6,6 +6,7 @@ invisible=false
port=19132
memory-limit=512M
last-update=false
update-channel=stable
white-list=false
debug=2
max-players=20