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! * Full Creative mode!
* Plugin API * Plugin API
* Custom world generation * Custom world generation
* Update Channels!! (stable / dev)
How to contact me How to contact me

View File

@ -17,7 +17,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles
### Alpha v1.1 ### Alpha v1.1
## Beta (Survival) ## Beta (Survival)
- Random Chunk Updates - Random Chunk Updates
- Mob spawning, item pick up - 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()){ if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
console("[INFO] Checking for new server version"); console("[INFO] Checking for new server version");
console("[INFO] Last check: ".date("Y-m-d H:i:s", $this->getProperty("last-update"))); 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); $channel = "stable";
if($info === false or !isset($info["updated_at"])){ if($this->getProperty("update-channel") == "dev" or $this->getProperty("update-channel") == "development"){
console("[ERROR] GitHub API Error"); $channel = "dev";
}else{ }
$last = new DateTime($info["updated_at"]);
$last = $last->getTimestamp(); if($channel === "dev"){
if($last >= $this->getProperty("last-update") and $this->getProperty("last-update") !== false){ $info = json_decode(Utils::curl_get("https://api.github.com/repos/shoghicp/PocketMine-MP"), true);
console("[NOTICE] PocketMine-MP has been updated at ".date("Y-m-d H:i:s", $last)); if($info === false or !isset($info["updated_at"])){
console("[NOTICE] If you want to update, get the latest version at https://github.com/shoghicp/PocketMine-MP/archive/master.zip"); console("[ERROR] GitHub API Error");
console("[NOTICE] This message will dissapear when you issue the command \"/update-done\"");
sleep(3);
}else{ }else{
$last = time(); $last = new DateTime($info["updated_at"]);
$this->setProperty("last-update", $last); $last = $last->getTimestamp();
console("[INFO] This is the latest version"); 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")){ if(file_exists(FILE_PATH."data/maps/level.dat")){

View File

@ -40,4 +40,4 @@ define("CURRENT_VERSION", 1);
define("LOG", true); define("LOG", true);
define("MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78"); define("MAGIC", "\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78");
define("TEST_MD5", "5ca8eced50a5801619f7ae86d631a4e7"); 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 port=19132
memory-limit=512M memory-limit=512M
last-update=false last-update=false
update-channel=stable
white-list=false white-list=false
debug=2 debug=2
max-players=20 max-players=20