From f825c0c1111add5ca46c8b0121d15a59564135b7 Mon Sep 17 00:00:00 2001 From: kremsy Date: Fri, 31 Jan 2014 16:11:14 +0100 Subject: [PATCH] changed all client Exceptions from Exception to \Exception --- .../core/Callbacks/CallbackManager.php | 3 +- .../core/Configurators/ScriptSettings.php | 5 +- .../core/Configurators/ServerSettings.php | 6 +-- application/core/ManiaControl.php | 9 ++-- .../core/Manialinks/ManialinkManager.php | 3 +- application/core/Players/PlayerActions.php | 19 ++++--- application/core/Players/PlayerCommands.php | 7 ++- application/core/Server/Server.php | 51 +++++++++---------- application/core/Server/ServerCommands.php | 13 +++-- application/plugins/ChatMessagePlugin.php | 34 ++++++------- application/plugins/Donations.php | 7 ++- application/plugins/SlotMachine.php | 3 +- 12 files changed, 74 insertions(+), 86 deletions(-) diff --git a/application/core/Callbacks/CallbackManager.php b/application/core/Callbacks/CallbackManager.php index a9ae75ad..f3d02f78 100644 --- a/application/core/Callbacks/CallbackManager.php +++ b/application/core/Callbacks/CallbackManager.php @@ -3,7 +3,6 @@ namespace ManiaControl\Callbacks; use ManiaControl\ManiaControl; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Class for managing Server and ManiaControl Callbacks @@ -193,7 +192,7 @@ class CallbackManager { try { $callbacks = $this->maniaControl->client->executeCallbacks(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Error reading server callbacks. " . $e->getMessage()); return; } diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index f38adef9..55f9f5fe 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -13,7 +13,6 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Class offering a Configurator for Script Settings @@ -126,7 +125,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { try { $this->maniaControl->client->setModeScriptSettings($loadedSettings); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error('Error occured: ' . $e->getMessage()); return false; } @@ -379,7 +378,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { try { $success = $this->maniaControl->client->setModeScriptSettings($newSettings); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return false; } diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index 766aa75f..27c3dba4 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -13,7 +13,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; + /** * Class offering a Configurator for Server Settings @@ -115,7 +115,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { try { $this->maniaControl->client->setServerOptions($serverSettings); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error('Error occured: ' . $e->getMessage()); return false; } @@ -332,7 +332,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { try { $this->maniaControl->client->setServerOptions($newSettings); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error('Error occured: ' . $e->getMessage()); return false; } diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 41c1ea55..2e977e57 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -19,7 +19,6 @@ use ManiaControl\Server\Server; use ManiaControl\Settings\SettingManager; use ManiaControl\Statistics\StatisticManager; use Maniaplanet\DedicatedServer\Connection; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; require_once __DIR__ . '/Maniaplanet/DedicatedServer/Connection.php'; require_once __DIR__ . '/GbxDataFetcher/gbxdatafetcher.inc.php'; @@ -322,14 +321,14 @@ class ManiaControl implements CommandListener { try { $this->client = Connection::factory($host, $port, self::CONNECT_TIMEOUT, $login, $pass); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't authenticate on server with user '{$login}'! " . $e->getMessage(), E_USER_ERROR); } // Enable callback system try { $this->client->enableCallbacks(true); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't enable callbacks! " . $e->getMessage(), E_USER_ERROR); } @@ -357,7 +356,7 @@ class ManiaControl implements CommandListener { try { $scriptSettings = $this->client->getModeScriptSettings(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't get mode script settings. " . $e->getMessage()); return; } @@ -369,7 +368,7 @@ class ManiaControl implements CommandListener { $scriptSettings['S_UseScriptCallbacks'] = true; try { $this->client->setModeScriptSettings($scriptSettings); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't set mode script settings to enable script callbacks. " . $e->getMessage()); return; } diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index 43bf9659..19a187a4 100644 --- a/application/core/Manialinks/ManialinkManager.php +++ b/application/core/Manialinks/ManialinkManager.php @@ -10,7 +10,6 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Manialink manager class @@ -149,7 +148,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener return $success; } - } catch(Exception $e) { + } catch(\Exception $e) { return false; } diff --git a/application/core/Players/PlayerActions.php b/application/core/Players/PlayerActions.php index 91fe5abb..5e6c0b0f 100644 --- a/application/core/Players/PlayerActions.php +++ b/application/core/Players/PlayerActions.php @@ -11,7 +11,6 @@ use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * PlayerActions Class @@ -86,7 +85,7 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -94,7 +93,7 @@ class PlayerActions { if($userIsAbleToSelect) { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -131,7 +130,7 @@ class PlayerActions { try { $this->maniaControl->client->forcePlayerTeam($target->login, $teamId); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -168,7 +167,7 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, $spectatorState); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -182,7 +181,7 @@ class PlayerActions { // Free player slot try { $this->maniaControl->client->spectatorReleasePlayerSlot($target->login); - } catch(Exception $e) { + } catch(\Exception $e) { //do nothing } } @@ -206,7 +205,7 @@ class PlayerActions { try { $this->maniaControl->client->unIgnore($targetLogin); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $adminLogin); return; } @@ -235,7 +234,7 @@ class PlayerActions { try { $this->maniaControl->client->ignore($targetLogin); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -350,7 +349,7 @@ class PlayerActions { } else { $this->maniaControl->client->kick($target->login, $message); } - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } @@ -387,7 +386,7 @@ class PlayerActions { try { $this->maniaControl->client->ban($target->login, $message); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $admin->login); return; } diff --git a/application/core/Players/PlayerCommands.php b/application/core/Players/PlayerCommands.php index 6743b665..4cf9f1f4 100644 --- a/application/core/Players/PlayerCommands.php +++ b/application/core/Players/PlayerCommands.php @@ -8,7 +8,6 @@ use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Class offering various Admin Commands related to Players @@ -86,7 +85,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener { try { $this->maniaControl->client->autoTeamBalance(); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -252,7 +251,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener { for($i = 0; $i < $amount; $i++) { $this->maniaControl->client->connectFakePlayer(); } - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -274,7 +273,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener { try { $this->maniaControl->client->disconnectFakePlayer('*'); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } diff --git a/application/core/Server/Server.php b/application/core/Server/Server.php index c37a3880..0d78b4ae 100644 --- a/application/core/Server/Server.php +++ b/application/core/Server/Server.php @@ -7,7 +7,6 @@ use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use Maniaplanet\DedicatedServer\Structures\SystemInfos; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Class providing Information about theconnected ManiaPlanet Server @@ -76,13 +75,13 @@ class Server implements CallbackListener { ) ON DUPLICATE KEY UPDATE `index` = LAST_INSERT_ID(`index`);"; $statement = $mysqli->prepare($query); - if($mysqli->error) { + if ($mysqli->error) { trigger_error($mysqli->error); return; } $statement->bind_param('s', $this->login); $statement->execute(); - if($statement->error) { + if ($statement->error) { trigger_error($statement->error); $statement->close(); return; @@ -105,12 +104,12 @@ class Server implements CallbackListener { UNIQUE KEY `login` (`login`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Servers' AUTO_INCREMENT=1;"; $statement = $mysqli->prepare($query); - if($mysqli->error) { + if ($mysqli->error) { trigger_error($mysqli->error, E_USER_ERROR); return false; } $statement->execute(); - if($statement->error) { + if ($statement->error) { trigger_error($statement->error, E_USER_ERROR); return false; } @@ -133,10 +132,10 @@ class Server implements CallbackListener { * @return string */ public function getDataDirectory() { - if($this->dataDirectory == '') { + if ($this->dataDirectory == '') { try { $this->dataDirectory = $this->maniaControl->client->gameDataDirectory(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't get data directory. " . $e->getMessage()); return null; } @@ -151,7 +150,7 @@ class Server implements CallbackListener { */ public function getMapsDirectory() { $dataDirectory = $this->getDataDirectory(); - if(!$dataDirectory) { + if (!$dataDirectory) { return null; } return "{$dataDirectory}Maps/"; @@ -164,7 +163,7 @@ class Server implements CallbackListener { * @return bool */ public function checkAccess($directory) { - if(!$directory) { + if (!$directory) { return false; } return (is_dir($directory) && is_writable($directory)); @@ -177,11 +176,11 @@ class Server implements CallbackListener { * @return array */ public function getInfo($detailed = false) { - if($detailed) { + if ($detailed) { $login = $this->login; try { $info = $this->maniaControl->client->getDetailedPlayerInfo($login); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch detailed server info. " . $e->getMessage()); return null; } @@ -189,7 +188,7 @@ class Server implements CallbackListener { } try { $info = $this->maniaControl->client->getMainServerPlayerInfo(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch server info. " . $e->getMessage()); return null; } @@ -204,7 +203,7 @@ class Server implements CallbackListener { public function getOptions() { try { $options = $this->maniaControl->client->getServerOptions(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch server options. " . $e->getMessage()); return null; } @@ -220,7 +219,7 @@ class Server implements CallbackListener { public function getName() { try { $name = $this->maniaControl->client->getServerName(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch server name. " . $e->getMessage()); return null; } @@ -236,7 +235,7 @@ class Server implements CallbackListener { public function getVersion() { try { $version = $this->maniaControl->client->getVersion(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch server version. " . $e->getMessage()); return null; } @@ -251,7 +250,7 @@ class Server implements CallbackListener { public function getSystemInfo() { try { $systemInfo = $this->maniaControl->client->getSystemInfo(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch server system info. " . $e->getMessage()); return null; } @@ -267,17 +266,17 @@ class Server implements CallbackListener { * @return int | string */ public function getGameMode($stringValue = false, $parseValue = null) { - if(is_int($parseValue)) { + if (is_int($parseValue)) { $gameMode = $parseValue; } else { try { $gameMode = $this->maniaControl->client->getGameMode(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't fetch current game mode. " . $e->getMessage()); return null; } } - if($stringValue) { + if ($stringValue) { switch($gameMode) { case 0: return 'Script'; @@ -309,7 +308,7 @@ class Server implements CallbackListener { public function getValidationReplay(Player $player) { try { $replay = $this->maniaControl->client->getValidationReplay($player->login); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't get validation replay of '{$player->login}'. " . $e->getMessage()); return null; } @@ -324,7 +323,7 @@ class Server implements CallbackListener { */ public function getGhostReplay(Player $player) { $dataDir = $this->getDataDirectory(); - if(!$this->checkAccess($dataDir)) { + if (!$this->checkAccess($dataDir)) { return null; } @@ -337,14 +336,14 @@ class Server implements CallbackListener { // Save ghost replay try { $this->maniaControl->client->saveBestGhostsReplay($player->login, $fileName); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't save ghost replay. " . $e->getMessage()); return null; } // Load replay file $ghostReplay = file_get_contents("{$dataDir}Replays/{$fileName}"); - if(!$ghostReplay) { + if (!$ghostReplay) { trigger_error("Couldn't retrieve saved ghost replay."); return null; } @@ -360,7 +359,7 @@ class Server implements CallbackListener { public function waitForStatus($statusCode = 4) { $response = $this->maniaControl->client->getStatus(); // Check if server has the given status - if($response->code === 4) { + if ($response->code === 4) { return true; } // Server not yet in given status - Wait for it... @@ -372,11 +371,11 @@ class Server implements CallbackListener { while($response->code !== 4) { sleep(1); $response = $this->maniaControl->client->getStatus(); - if($lastStatus !== $response['Name']) { + if ($lastStatus !== $response['Name']) { $this->maniaControl->log("New Status: {$response['Name']}"); $lastStatus = $response['Name']; } - if(time() - $maxWaitTime > $waitBegin) { + if (time() - $maxWaitTime > $waitBegin) { // It took too long to reach the status trigger_error("Server couldn't reach status {$statusCode} after {$maxWaitTime} seconds! "); return false; diff --git a/application/core/Server/ServerCommands.php b/application/core/Server/ServerCommands.php index b2b52ae8..2c410625 100644 --- a/application/core/Server/ServerCommands.php +++ b/application/core/Server/ServerCommands.php @@ -12,7 +12,6 @@ use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Class offering various commands related to the dedicated server @@ -220,7 +219,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage $serverName = $params[1]; try { $this->maniaControl->client->setServerName($serverName); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -247,7 +246,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage } try { $this->maniaControl->client->setServerPassword($password); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -274,7 +273,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage } try { $this->maniaControl->client->setServerPasswordForSpectator($password); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -309,7 +308,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage try { $this->maniaControl->client->setMaxPlayers($amount); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -345,7 +344,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage try { $this->maniaControl->client->setMaxSpectators($amount); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -361,7 +360,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage private function shutdownServer($login = '#') { try { $this->maniaControl->client->stopServer(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Server shutdown command from '{login}' failed. " . $e->getMessage()); return false; } diff --git a/application/plugins/ChatMessagePlugin.php b/application/plugins/ChatMessagePlugin.php index c75ab2af..17cd1bbf 100644 --- a/application/plugins/ChatMessagePlugin.php +++ b/application/plugins/ChatMessagePlugin.php @@ -4,7 +4,6 @@ use ManiaControl\Commands\CommandListener; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Plugins\Plugin; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * ManiaControl Chat-Message Plugin @@ -25,7 +24,6 @@ class ChatMessagePlugin implements CommandListener, Plugin { * Private properties */ /** - * * @var maniaControl $maniaControl */ private $maniaControl = null; @@ -104,7 +102,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_hi(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHello All!'; @@ -121,7 +119,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_bye(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iBye $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iI have to go... Bye All!'; @@ -139,7 +137,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_thx(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iThanks All!'; @@ -157,7 +155,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_gg(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Game All!'; @@ -175,7 +173,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_gl(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck All!'; @@ -193,7 +191,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_hf(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iHave Fun All!'; @@ -211,7 +209,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_glhf(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iGood Luck and Have Fun All!'; @@ -229,7 +227,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_ns(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice Shot!'; @@ -247,7 +245,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { public function chat_n1(array $chat, Player $player) { $command = explode(" ", $chat[1][2]); - if(isset($command[1])) { + if (isset($command[1])) { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One $z$<' . $this->getTarget($command[1]) . '$>$i!'; } else { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iNice One!'; @@ -313,7 +311,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { $message = '$39F Thanks for Playing, please come back soon!$z'; try { $this->maniaControl->client->kick($player->login, $message); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -332,7 +330,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { $message = '$39F Thanks for Playing, please come back soon!$z'; try { $this->maniaControl->client->kick($player->login, $message); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -348,11 +346,11 @@ class ChatMessagePlugin implements CommandListener, Plugin { $msg = '$g[$<' . $player->nickname . '$>$s] $ff0$iAway From Keyboard!'; $this->maniaControl->chat->sendChat($msg, null, false); - if($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) { + if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_AFK_FORCE_SPEC)) { // force into spec try { $this->maniaControl->client->forceSpectator($player->login, 3); - } catch(Exception $e) { + } catch(\Exception $e) { $this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login); return; } @@ -360,7 +358,7 @@ class ChatMessagePlugin implements CommandListener, Plugin { // free player slot try { $this->maniaControl->client->spectatorReleasePlayerSlot($player->login); - } catch(Exception $e) { + } catch(\Exception $e) { //to nothing } } @@ -377,13 +375,13 @@ class ChatMessagePlugin implements CommandListener, Plugin { $pid = 1; foreach($this->maniaControl->playerManager->getPlayers() as $player) { - if($login == $player->login || $login == $pid || $login == $player->nickname) { + if ($login == $player->login || $login == $pid || $login == $player->nickname) { return $player->nickname; } $pid++; } - if($login == 'lj') { + if ($login == 'lj') { return $player->nickname; } diff --git a/application/plugins/Donations.php b/application/plugins/Donations.php index a6435b5e..85a26a44 100644 --- a/application/plugins/Donations.php +++ b/application/plugins/Donations.php @@ -16,7 +16,6 @@ use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; /** * Donation plugin @@ -336,7 +335,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $message = 'Donate ' . $amount . ' Planets to $<' . $receiverName . '$>?'; try { $bill = $this->maniaControl->client->sendBill($player->login, $amount, $message, $receiver); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't create donation of {$amount} planets from '{$player->login}' for '{$receiver}'. " . $e->getMessage()); $this->maniaControl->chat->sendError("Creating donation failed.", $player->login); return false; @@ -379,7 +378,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { try { $bill = $this->maniaControl->client->pay($receiver, $amount, $message); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't retrieve server planets. " . $e->getMessage()); trigger_error("Couldn't create payout of {$amount} planets by '{$player->login}' for '{$receiver}'. " . $e->getMessage()); $this->maniaControl->chat->sendError("Creating payout failed.", $player->login); @@ -404,7 +403,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { } try { $planets = $this->maniaControl->client->getServerPlanets(); - } catch(Exception $e) { + } catch(\Exception $e) { trigger_error("Couldn't retrieve server planets. " . $e->getMessage()); return false; } diff --git a/application/plugins/SlotMachine.php b/application/plugins/SlotMachine.php index 861809cd..e6619c1b 100644 --- a/application/plugins/SlotMachine.php +++ b/application/plugins/SlotMachine.php @@ -15,7 +15,6 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; -use Maniaplanet\DedicatedServer\Xmlrpc\Exception; class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswerListener, TimerListener { /** @@ -468,7 +467,7 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer try { $billId = $this->maniaControl->client->pay($player->login, (int)$balance, $message); - } catch(Exception $e) { + } catch(\Exception $e) { return; }