mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
Github API error handling
This commit is contained in:
parent
3b800ff6b4
commit
67c9181a06
@ -93,19 +93,24 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
|
||||
$this->server = new PocketMinecraftServer($this->getProperty("server-name"), $this->getProperty("gamemode"), $this->getProperty("seed"), $this->getProperty("protocol"), $this->getProperty("port"), $this->getProperty("server-id"));
|
||||
$this->server->api = $this;
|
||||
if($this->getProperty("last-update") === false or ($this->getProperty("last-update") + 3600) < time()){
|
||||
console("[INFO] Checking for new version...");
|
||||
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);
|
||||
$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);
|
||||
if($info === false or !isset($info["updated_at"])){
|
||||
console("[ERROR] GitHub API Error");
|
||||
}else{
|
||||
$last = time();
|
||||
$this->setProperty("last-update", $last);
|
||||
console("[INFO] Last check at ".date("Y-m-d H:i:s", $last));
|
||||
$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);
|
||||
}else{
|
||||
$last = time();
|
||||
$this->setProperty("last-update", $last);
|
||||
console("[INFO] This is the latest version");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(file_exists(FILE_PATH."data/maps/level.dat")){
|
||||
|
Loading…
x
Reference in New Issue
Block a user