From 89ec2aa9a5ecebf1101634e614299c41f0744de1 Mon Sep 17 00:00:00 2001 From: kremsy Date: Mon, 9 Dec 2013 22:20:30 +0100 Subject: [PATCH] improved command manager --- application/core/Admin/AuthCommands.php | 6 ++--- application/core/Commands/CommandManager.php | 9 ++++--- application/core/Server/ServerCommands.php | 28 ++++++++++---------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/application/core/Admin/AuthCommands.php b/application/core/Admin/AuthCommands.php index ea03d9d7..a42e52f5 100644 --- a/application/core/Admin/AuthCommands.php +++ b/application/core/Admin/AuthCommands.php @@ -26,9 +26,9 @@ class AuthCommands implements CommandListener { $this->maniaControl = $maniaControl; // Register for commands - $this->maniaControl->commandManager->registerCommandListener('/addsuperadmin', $this, 'command_AddSuperAdmin'); - $this->maniaControl->commandManager->registerCommandListener('/addadmin', $this, 'command_AddAdmin'); - $this->maniaControl->commandManager->registerCommandListener('/addop', $this, 'command_AddOperator'); + $this->maniaControl->commandManager->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin',true); + $this->maniaControl->commandManager->registerCommandListener('addadmin', $this, 'command_AddAdmin',true); + $this->maniaControl->commandManager->registerCommandListener('addop', $this, 'command_AddOperator',true); } /** diff --git a/application/core/Commands/CommandManager.php b/application/core/Commands/CommandManager.php index 0e22f7b0..708b7d4a 100644 --- a/application/core/Commands/CommandManager.php +++ b/application/core/Commands/CommandManager.php @@ -78,15 +78,16 @@ class CommandManager implements CallbackListener { return; } // Handle command - $command = explode(" ", substr($callback[1][2], 1)); - $command = strtolower($command[0]); + $commandArray = explode(" ", substr($callback[1][2], 1)); + $command = strtolower($commandArray[0]); if(substr($command,0,1) == "/" || $command == "admin"){ //admin command $commandListeners = $this->adminCommandListeners; if($command == "admin"){ - //TODO make /admin working + $command = strtolower($commandArray[1]); + }else{ + $command = substr($command, 1); //remove / } - $command = substr($command, 1); }else{ //user command $commandListeners = $this->commandListeners; } diff --git a/application/core/Server/ServerCommands.php b/application/core/Server/ServerCommands.php index 82eccc51..e0ad01f5 100644 --- a/application/core/Server/ServerCommands.php +++ b/application/core/Server/ServerCommands.php @@ -34,20 +34,20 @@ class ServerCommands implements CallbackListener, CommandListener { $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_5_SECOND, $this, 'each5Seconds'); // Register for commands - $this->maniaControl->commandManager->registerCommandListener('/setpwd', $this, 'command_SetPwd'); - $this->maniaControl->commandManager->registerCommandListener('/setservername', $this, 'command_SetServerName'); - $this->maniaControl->commandManager->registerCommandListener('/setmaxplayers', $this, 'command_SetMaxPlayers'); - $this->maniaControl->commandManager->registerCommandListener('/setmaxspectators', $this, 'command_SetMaxSpectators'); - $this->maniaControl->commandManager->registerCommandListener('/setspecpwd', $this, 'command_SetSpecPwd'); - $this->maniaControl->commandManager->registerCommandListener('/shutdown', $this, 'command_Shutdown'); - $this->maniaControl->commandManager->registerCommandListener('/shutdownserver', $this, 'command_ShutdownServer'); - $this->maniaControl->commandManager->registerCommandListener('/systeminfo', $this, 'command_SystemInfo'); - $this->maniaControl->commandManager->registerCommandListener('/hideserver', $this, 'command_HideServer'); - $this->maniaControl->commandManager->registerCommandListener('/showserver', $this, 'command_ShowServer'); - $this->maniaControl->commandManager->registerCommandListener('/enablemapdownload', $this, 'command_EnableMapDownload'); - $this->maniaControl->commandManager->registerCommandListener('/disablemapdownload', $this, 'command_DisableMapDownload'); - $this->maniaControl->commandManager->registerCommandListener('/enablehorns', $this, 'command_EnableHorns'); - $this->maniaControl->commandManager->registerCommandListener('/disablehorns', $this, 'command_DisableHorns'); + $this->maniaControl->commandManager->registerCommandListener('setpwd', $this, 'command_SetPwd',true); + $this->maniaControl->commandManager->registerCommandListener('setservername', $this, 'command_SetServerName',true); + $this->maniaControl->commandManager->registerCommandListener('setmaxplayers', $this, 'command_SetMaxPlayers',true); + $this->maniaControl->commandManager->registerCommandListener('setmaxspectators', $this, 'command_SetMaxSpectators',true); + $this->maniaControl->commandManager->registerCommandListener('setspecpwd', $this, 'command_SetSpecPwd',true); + $this->maniaControl->commandManager->registerCommandListener('shutdown', $this, 'command_Shutdown',true); + $this->maniaControl->commandManager->registerCommandListener('shutdownserver', $this, 'command_ShutdownServer',true); + $this->maniaControl->commandManager->registerCommandListener('systeminfo', $this, 'command_SystemInfo',true); + $this->maniaControl->commandManager->registerCommandListener('hideserver', $this, 'command_HideServer',true); + $this->maniaControl->commandManager->registerCommandListener('showserver', $this, 'command_ShowServer',true); + $this->maniaControl->commandManager->registerCommandListener('enablemapdownload', $this, 'command_EnableMapDownload',true); + $this->maniaControl->commandManager->registerCommandListener('disablemapdownload', $this, 'command_DisableMapDownload',true); + $this->maniaControl->commandManager->registerCommandListener('enablehorns', $this, 'command_EnableHorns',true); + $this->maniaControl->commandManager->registerCommandListener('disablehorns', $this, 'command_DisableHorns',true); } /**