removed old timed callbacks
This commit is contained in:
committed by
Steffen Schröder
parent
620807c419
commit
1c0dd7e83d
@ -7,6 +7,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
@ -18,7 +19,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
*/
|
||||
class ServerCommands implements CallbackListener, CommandListener, ManialinkPageAnswerListener {
|
||||
class ServerCommands implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
@ -42,7 +43,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_5_SECOND, $this, 'each5Seconds');
|
||||
$this->maniaControl->timerManager->registerTimerListening($this, 'each5Seconds', 5000);
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
||||
|
||||
// Register for commands
|
||||
@ -69,14 +70,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
|
||||
$pauseExists = false;
|
||||
foreach($scriptInfos->commandDescs as $param) {
|
||||
if($param->name == "Command_ForceWarmUp") {
|
||||
if ($param->name == "Command_ForceWarmUp") {
|
||||
$pauseExists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Set Pause
|
||||
if($pauseExists) {
|
||||
if ($pauseExists) {
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||
$itemQuad->setAction(self::ACTION_SET_PAUSE);
|
||||
@ -98,7 +99,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_CancelVote(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -117,7 +118,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
*/
|
||||
public function setPause(array $callback) {
|
||||
$success = $this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
||||
if(!$success) {
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError("Error while setting the pause");
|
||||
}
|
||||
}
|
||||
@ -125,21 +126,21 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
/**
|
||||
* Check stuff each 5 seconds
|
||||
*
|
||||
* @param array $callback
|
||||
* @param $timer
|
||||
* @return bool
|
||||
*/
|
||||
public function each5Seconds(array $callback) {
|
||||
public function each5Seconds($timer) {
|
||||
// Empty shutdown
|
||||
if($this->serverShutdownEmpty) {
|
||||
if ($this->serverShutdownEmpty) {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
if(count($players) <= 0) {
|
||||
if (count($players) <= 0) {
|
||||
$this->shutdownServer('empty');
|
||||
}
|
||||
}
|
||||
|
||||
// Delayed shutdown
|
||||
if($this->serverShutdownTime > 0) {
|
||||
if(time() >= $this->serverShutdownTime) {
|
||||
if ($this->serverShutdownTime > 0) {
|
||||
if (time() >= $this->serverShutdownTime) {
|
||||
$this->shutdownServer('delayed');
|
||||
}
|
||||
}
|
||||
@ -152,7 +153,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SystemInfo(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
@ -168,17 +169,17 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_ShutdownServer(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
// Check for delayed shutdown
|
||||
$params = explode(' ', $chat[1][2]);
|
||||
if(count($params) >= 2) {
|
||||
if (count($params) >= 2) {
|
||||
$param = $params[1];
|
||||
if($param == 'empty') {
|
||||
if ($param == 'empty') {
|
||||
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
||||
if($this->serverShutdownEmpty) {
|
||||
if ($this->serverShutdownEmpty) {
|
||||
$this->maniaControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $player->login);
|
||||
return;
|
||||
}
|
||||
@ -186,7 +187,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
return;
|
||||
}
|
||||
$delay = (int)$param;
|
||||
if($delay <= 0) {
|
||||
if ($delay <= 0) {
|
||||
// Cancel shutdown
|
||||
$this->serverShutdownTime = -1;
|
||||
$this->maniaControl->chat->sendInformation("Delayed shutdown cancelled!", $player->login);
|
||||
@ -207,12 +208,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetServerName(array $chat, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$params = explode(' ', $chat[1][2], 2);
|
||||
if(count($params) < 2) {
|
||||
if (count($params) < 2) {
|
||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setservername ManiaPlanet Server', $player->login);
|
||||
return;
|
||||
}
|
||||
@ -233,14 +234,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetPwd(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||
$password = '';
|
||||
$successMessage = 'Password removed!';
|
||||
if(isset($messageParts[1])) {
|
||||
if (isset($messageParts[1])) {
|
||||
$password = $messageParts[1];
|
||||
$successMessage = "Password changed to: '{$password}'!";
|
||||
}
|
||||
@ -260,14 +261,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetSpecPwd(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||
$password = '';
|
||||
$successMessage = 'Spectator password removed!';
|
||||
if(isset($messageParts[1])) {
|
||||
if (isset($messageParts[1])) {
|
||||
$password = $messageParts[1];
|
||||
$successMessage = "Spectator password changed to: '{$password}'!";
|
||||
}
|
||||
@ -287,22 +288,22 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetMaxPlayers(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||
if(!isset($messageParts[1])) {
|
||||
if (!isset($messageParts[1])) {
|
||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
||||
return;
|
||||
}
|
||||
$amount = $messageParts[1];
|
||||
if(!is_numeric($amount)) {
|
||||
if (!is_numeric($amount)) {
|
||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
||||
return;
|
||||
}
|
||||
$amount = (int)$amount;
|
||||
if($amount < 0) {
|
||||
if ($amount < 0) {
|
||||
$amount = 0;
|
||||
}
|
||||
|
||||
@ -323,22 +324,22 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_SetMaxSpectators(array $chatCallback, Player $player) {
|
||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||
if(!isset($messageParts[1])) {
|
||||
if (!isset($messageParts[1])) {
|
||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
||||
return;
|
||||
}
|
||||
$amount = $messageParts[1];
|
||||
if(!is_numeric($amount)) {
|
||||
if (!is_numeric($amount)) {
|
||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
||||
return;
|
||||
}
|
||||
$amount = (int)$amount;
|
||||
if($amount < 0) {
|
||||
if ($amount < 0) {
|
||||
$amount = 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user