From 332f8d76fb8371f7019320d6a86d8d885d04bd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 27 Apr 2014 15:21:57 +0200 Subject: [PATCH] refactoring and improvements --- application/core/Files/AsynchronousFileReader.php | 5 +++-- application/core/ManiaControl.php | 5 +++-- application/core/Server/Server.php | 1 + application/core/Server/UsageReporter.php | 1 - application/core/Update/PluginInstallMenu.php | 3 ++- application/plugins/ChatMessagePlugin.php | 11 +++++------ application/plugins/LocalRecords.php | 2 ++ 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/application/core/Files/AsynchronousFileReader.php b/application/core/Files/AsynchronousFileReader.php index 34aa8bb1..7701a8ea 100644 --- a/application/core/Files/AsynchronousFileReader.php +++ b/application/core/Files/AsynchronousFileReader.php @@ -2,6 +2,7 @@ namespace ManiaControl\Files; +use cURL\Event; use cURL\Exception; use cURL\Request; use cURL\Response; @@ -86,7 +87,7 @@ class AsynchronousFileReader { ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // ->set(CURLOPT_RETURNTRANSFER, true); - $request->addListener('complete', function (\cURL\Event $event) use (&$function) { + $request->addListener('complete', function (Event $event) use (&$function) { /** @var Response $response */ $response = $event->response; @@ -156,7 +157,7 @@ class AsynchronousFileReader { ->set(CURLOPT_USERAGENT, 'ManiaControl v' . ManiaControl::VERSION) // ->set(CURLOPT_RETURNTRANSFER, true); - $request->addListener('complete', function (\cURL\Event $event) use (&$function) { + $request->addListener('complete', function (Event $event) use (&$function) { /** @var Response $response */ $response = $event->response; $error = ""; diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 0f20f122..eeb0fa50 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -25,6 +25,7 @@ use ManiaControl\Update\UpdateManager; use Maniaplanet\DedicatedServer\Connection; use Maniaplanet\DedicatedServer\Xmlrpc\Exception; use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException; +use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; require_once __DIR__ . '/Libs/Maniaplanet/DedicatedServer/Connection.php'; require_once __DIR__ . '/Libs/GbxDataFetcher/gbxdatafetcher.inc.php'; @@ -61,7 +62,7 @@ class ManiaControl implements CommandListener, TimerListener { public $authenticationManager = null; public $callbackManager = null; public $chat = null; - public $config = null; + public $config = null; public $configurator = null; /** @var Connection $client */ public $client = null; @@ -435,7 +436,7 @@ class ManiaControl implements CommandListener, TimerListener { $this->client->setModeScriptSettings($scriptSettings); } catch(Exception $e) { //TODO temp added 19.04.2014 - $this->maniaControl->errorHandler->triggerDebugNotice("Exception line 437 ManiaControl.php " . $e->getMessage()); + $this->errorHandler->triggerDebugNotice("Exception line 437 ManiaControl.php " . $e->getMessage()); trigger_error("Couldn't set mode script settings to enable script callbacks. " . $e->getMessage()); return; diff --git a/application/core/Server/Server.php b/application/core/Server/Server.php index 9b462794..ca1f82cf 100644 --- a/application/core/Server/Server.php +++ b/application/core/Server/Server.php @@ -24,6 +24,7 @@ class Server implements CallbackListener { /* * Public Properties */ + /** @var Config $config */ public $config = null; public $index = -1; public $ip = null; diff --git a/application/core/Server/UsageReporter.php b/application/core/Server/UsageReporter.php index dd9f2d4e..ce99517d 100644 --- a/application/core/Server/UsageReporter.php +++ b/application/core/Server/UsageReporter.php @@ -7,7 +7,6 @@ use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Plugins\Plugin; use Maniaplanet\DedicatedServer\Xmlrpc\Exception; -use Maniaplanet\DedicatedServer\Xmlrpc\FatalException; /** * Class reporting ManiaControl Usage for the Server diff --git a/application/core/Update/PluginInstallMenu.php b/application/core/Update/PluginInstallMenu.php index fbe65207..50bea15d 100644 --- a/application/core/Update/PluginInstallMenu.php +++ b/application/core/Update/PluginInstallMenu.php @@ -16,6 +16,7 @@ use ManiaControl\Files\FileUtil; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; +use ManiaControl\Plugins\Plugin; /** * Configurator for enabling and disabling Plugins @@ -100,7 +101,7 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink if ($pluginList && isset($pluginList[0])) { $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); $pluginIds = array(); - /** @var Plugin $class */ + /** @var Plugin $class */ foreach($pluginClasses as $class) { $pluginIds[] = $class::getId(); } diff --git a/application/plugins/ChatMessagePlugin.php b/application/plugins/ChatMessagePlugin.php index d196b4ef..b64712e0 100644 --- a/application/plugins/ChatMessagePlugin.php +++ b/application/plugins/ChatMessagePlugin.php @@ -389,20 +389,19 @@ class ChatMessagePlugin implements CommandListener, Plugin { * @return mixed */ private function getTarget($login) { - $pid = 1; - + /** @var Player $player */ + $player = null; foreach($this->maniaControl->playerManager->getPlayers() as $player) { - if ($login == $player->login || $login == $pid || $login == $player->nickname) { + if ($login == $player->login || $login == $player->pid || $login == $player->nickname) { return $player->nickname; } - $pid++; } - if ($login == 'lj' && $pid > 1) { + if ($player && $login == 'lj') { return $player->nickname; } - return $login; + return null; } /** diff --git a/application/plugins/LocalRecords.php b/application/plugins/LocalRecords.php index ca38044d..d15c3282 100644 --- a/application/plugins/LocalRecords.php +++ b/application/plugins/LocalRecords.php @@ -270,7 +270,9 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList // Check old record of the player $oldRecord = $this->getLocalRecord($map, $player); + $oldRank = -1; if ($oldRecord) { + $oldRank = $oldRecord->rank; if ($oldRecord->time < $time) { // Not improved return;