Ticks per Second info

This commit is contained in:
Shoghi Cervantes Pueyo
2012-12-17 19:50:55 +01:00
parent 745c300840
commit f42f2d5e82
4 changed files with 24 additions and 7 deletions

View File

@ -31,6 +31,7 @@ class ConsoleAPI{
$this->help = array();
$this->server = $server;
$this->input = fopen(FILE_PATH."console.in", "w+b");
$this->last = microtime(true);
}
public function init(){
@ -44,6 +45,11 @@ class ConsoleAPI{
public function defaultCommands($cmd, $params){
switch($cmd){
case "status":
case "lag":
$info = $this->server->debugInfo();
console("[INFO] TPS: ".$info["tps"].", Memory usage: ".$info["memory_usage"]." (Peak ".$info["memory_peak_usage"].")");
break;
case "update-done":
$this->server->api->setProperty("last-update", time());
break;
@ -175,6 +181,7 @@ class ConsoleAPI{
case "help":
case "?":
console("[INFO] /help: Show available commands");
console("[INFO] /status: Show server TPS and memory usage");
console("[INFO] /gamemode: Changes default gamemode");
console("[INFO] /difficulty: Changes difficulty");
console("[INFO] /say: Broadcasts mesages");
@ -197,7 +204,7 @@ class ConsoleAPI{
$this->help[strtolower(trim($cmd))] = array($help, $callback);
}
public function handle(){
public function handle($time){
while(($line = fgets($this->input)) !== false){
$line = trim($line);
if($line === ""){

View File

@ -66,7 +66,7 @@ class ServerAPI extends stdClass{ //Yay! I can add anything to this class in run
console("[NOTICE] Pocket-PHP-Minecraft 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/Pocket-Minecraft-PHP/archive/master.zip");
console("[NOTICE] This message will dissapear when you issue the command \"/update-done\"");
sleep(5);
sleep(3);
}else{
$last = time();
$this->setProperty("last-update", $last);