added //uptime

This commit is contained in:
kremsy 2015-07-19 16:48:34 +02:00
parent f47e36d001
commit f6e7535023
2 changed files with 34 additions and 1 deletions

View File

@ -1,3 +1,11 @@
###v0.16x###
#Additions
- added admin chatcommand //uptime which displays the time since when the server is running
- updated playerhitstructure with new properties
#Bug Fixes
- fixed some z positions to be in front of overlays (especially in Trackmania)
###v0.16###
#Additions

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Server;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
@ -17,7 +18,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
* @copyright 2014-2015 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class Server implements CallbackListener {
class Server implements CallbackListener, CommandListener {
/*
* Constants
*/
@ -85,6 +86,30 @@ class Server implements CallbackListener {
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
$this->maniaControl->getCommandManager()->registerCommandListener("uptime", $this, "chatUpTime", true, "Show how long the server is running.");
}
/**
* Displays how long the Server is running already in the Chat
*
* @param array $chatCallback
* @param \ManiaControl\Players\Player $player
*/
public function chatUpTime(array $chatCallback, Player $player) {
$networkStats = $this->maniaControl->getClient()->getNetworkStats();
$minutestotal = $networkStats->uptime / 60;
$hourstotal = $minutestotal / 60;
$days = intval($hourstotal / 24);
$hours = intval($hourstotal - 24 * $days);
$minutes = intval($minutestotal - 24 * 60 * $days - $hours * 60);
$days > 1 ? $dayString = 'days' : $dayString = 'day';
$hours > 1 ? $hourString = 'hours' : $hourString = 'hour';
$minutes > 1 ? $minuteString = 'minutes' : $minuteString = 'minute';
$this->maniaControl->getChat()->sendChat('Server is running since $<$fff' . $days . '$> ' . $dayString . ', $<$fff' . $hours . '$> ' . $hourString . ' and $<$fff' . $minutes . '$> ' . $minuteString, $player);
}
/**