mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-31 07:21:17 +00:00
Server restart without closing, added more info
This commit is contained in:
parent
29d253fd93
commit
fb019a88c1
@ -45,7 +45,12 @@ class ConsoleAPI{
|
|||||||
$this->server->api->setProperty("last-update", time());
|
$this->server->api->setProperty("last-update", time());
|
||||||
break;
|
break;
|
||||||
case "stop":
|
case "stop":
|
||||||
console("[INFO] Stopping server...");
|
console("[INFO] Stopping the server...");
|
||||||
|
$this->server->close();
|
||||||
|
break;
|
||||||
|
case "restart":
|
||||||
|
console("[INFO] Restarting the server...");
|
||||||
|
$this->server->api->restart = true;
|
||||||
$this->server->close();
|
$this->server->close();
|
||||||
break;
|
break;
|
||||||
case "banip":
|
case "banip":
|
||||||
@ -174,6 +179,7 @@ class ConsoleAPI{
|
|||||||
console("[INFO] /whitelist: Manages whitelisting");
|
console("[INFO] /whitelist: Manages whitelisting");
|
||||||
console("[INFO] /banip: Manages IP ban");
|
console("[INFO] /banip: Manages IP ban");
|
||||||
console("[INFO] /stop: Stops the server");
|
console("[INFO] /stop: Stops the server");
|
||||||
|
console("[INFO] /restart: Restarts the server");
|
||||||
foreach($this->help as $c => $h){
|
foreach($this->help as $c => $h){
|
||||||
console("[INFO] /$c: ".$h[0]);
|
console("[INFO] /$c: ".$h[0]);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class PlayerAPI{
|
|||||||
case "list":
|
case "list":
|
||||||
console("[INFO] Player list:");
|
console("[INFO] Player list:");
|
||||||
foreach($this->server->clients as $c){
|
foreach($this->server->clients as $c){
|
||||||
console("[INFO] ".$c->username." (".$c->ip.":".$c->port."), ClientID ".$c->clientID);
|
console("[INFO] ".$c->username." (".$c->ip.":".$c->port."), ClientID ".$c->clientID.", (".round($c->username->entity->position["x"], 2).", ".round($c->username->entity->position["y"], 2).", ".round($c->username->entity->position["z"], 2).")");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class ServerAPI extends stdClass{ //Yay! I can add anything to this class in runtime!
|
class ServerAPI extends stdClass{ //Yay! I can add anything to this class in runtime!
|
||||||
var $server;
|
var $server, $restart = false;
|
||||||
private $config, $apiList = array();
|
private $config, $apiList = array();
|
||||||
function __construct(){
|
function __construct(){
|
||||||
console("[INFO] Starting ServerAPI server handler...");
|
console("[INFO] Starting ServerAPI server handler...");
|
||||||
@ -260,6 +260,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
|
|||||||
|
|
||||||
public function start(){
|
public function start(){
|
||||||
$this->server->start();
|
$this->server->start();
|
||||||
|
return $this->restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ class PocketMinecraftServer extends stdClass{
|
|||||||
$this->save();
|
$this->save();
|
||||||
$this->stop = true;
|
$this->stop = true;
|
||||||
$this->trigger("onClose");
|
$this->trigger("onClose");
|
||||||
|
$this->interface->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function chat($owner, $text, $target = true){
|
public function chat($owner, $text, $target = true){
|
||||||
|
@ -48,8 +48,12 @@ class UDPSocket{
|
|||||||
$this->buffer = array();
|
$this->buffer = array();
|
||||||
$this->unblock();
|
$this->unblock();
|
||||||
}else{
|
}else{
|
||||||
socket_bind($this->sock, "0.0.0.0", $port);
|
if(socket_bind($this->sock, "0.0.0.0", $port) === true){
|
||||||
$this->unblock();
|
$this->unblock();
|
||||||
|
}else{
|
||||||
|
console("[ERROR] Couldn't bind to 0.0.0.0:".$port, true, true, 0);
|
||||||
|
die();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,12 @@ require_once("common/dependencies.php");
|
|||||||
require_once("classes/PocketMinecraftServer.class.php");
|
require_once("classes/PocketMinecraftServer.class.php");
|
||||||
require_once("classes/API/ServerAPI.php");
|
require_once("classes/API/ServerAPI.php");
|
||||||
|
|
||||||
|
while(true){
|
||||||
$server = new ServerAPI();
|
$server = new ServerAPI();
|
||||||
//You can add simple things here
|
//You can add simple things here
|
||||||
|
|
||||||
$server->start();
|
if($server->start() !== true){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console("[NOTICE] The server is restarting...", true, true, 0);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user