diff --git a/application/core/Chat.php b/application/core/Chat.php index a5f5d998..cfba7bfb 100644 --- a/application/core/Chat.php +++ b/application/core/Chat.php @@ -52,7 +52,7 @@ class Chat { */ public function sendInformation($message, $login = null, $prefix = true) { $format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_INFORMATION); - return $this->sendChat($format . $message, $login); + return $this->sendChat($format . $message, $login, $prefix); } /** @@ -111,7 +111,7 @@ class Chat { */ public function sendSuccess($message, $login = null, $prefix = true) { $format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_SUCCESS); - return $this->sendChat($format . $message, $login); + return $this->sendChat($format . $message, $login, $prefix); } /** @@ -137,7 +137,7 @@ class Chat { */ public function sendError($message, $login = null, $prefix = true) { $format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_ERROR); - return $this->sendChat($format . $message, $login); + return $this->sendChat($format . $message, $login, $prefix); } /** @@ -150,6 +150,6 @@ class Chat { */ public function sendUsageInfo($message, $login = null, $prefix = false) { $format = $this->maniaControl->settingManager->getSetting($this, self::SETTING_FORMAT_USAGEINFO); - return $this->sendChat($format . $message, $login); + return $this->sendChat($format . $message, $login, $prefix); } } diff --git a/application/core/Commands/HelpManager.php b/application/core/Commands/HelpManager.php index 3101685c..ab2ef474 100644 --- a/application/core/Commands/HelpManager.php +++ b/application/core/Commands/HelpManager.php @@ -54,10 +54,10 @@ class HelpManager implements CommandListener, CallbackListener { /** * Shows a list of Admin Commands * - * @param array $chat + * @param array $chatCallback * @param Player $player */ - public function command_adminHelp(array $chat, Player $player) { + public function command_adminHelp(array $chatCallback, Player $player) { $showCommands = array(); $registeredMethods = array(); foreach (array_reverse($this->adminCommands) as $command) { @@ -85,10 +85,10 @@ class HelpManager implements CommandListener, CallbackListener { /** * Shows a list of Player Commands * - * @param array $chat + * @param array $chatCallback * @param Player $player */ - public function command_playerHelp(array $chat, Player $player) { + public function command_playerHelp(array $chatCallback, Player $player) { $showCommands = array(); $registeredMethods = array(); foreach (array_reverse($this->playerCommands) as $command) { @@ -116,10 +116,10 @@ class HelpManager implements CommandListener, CallbackListener { /** * Shows a ManiaLink list of Player Commands * - * @param array $chat + * @param array $chatCallback * @param Player $player */ - public function command_playerHelpAll(array $chat, Player $player) { + public function command_playerHelpAll(array $chatCallback, Player $player) { $this->prepareHelpAll($this->playerCommands, $player); } @@ -237,10 +237,10 @@ class HelpManager implements CommandListener, CallbackListener { /** * Shows a ManiaLink list of Admin Commands * - * @param array $chat + * @param array $chatCallback * @param Player $player */ - public function command_adminHelpAll(array $chat, Player $player) { + public function command_adminHelpAll(array $chatCallback, Player $player) { $this->prepareHelpAll($this->adminCommands, $player); } diff --git a/application/core/ErrorHandler.php b/application/core/ErrorHandler.php index 317d196b..e6596e70 100644 --- a/application/core/ErrorHandler.php +++ b/application/core/ErrorHandler.php @@ -203,37 +203,29 @@ class ErrorHandler { * @return string */ public function getErrorTag($errorLevel) { - if ($errorLevel == E_NOTICE) { - return '[PHP NOTICE]'; + switch ($errorLevel) { + case E_NOTICE: + return '[PHP NOTICE]'; + case E_WARNING: + return '[PHP WARNING]'; + case E_ERROR: + return '[PHP ERROR]'; + case E_CORE_ERROR: + return '[PHP CORE ERROR]'; + case E_COMPILE_ERROR: + return '[PHP COMPILE ERROR]'; + case E_RECOVERABLE_ERROR: + return '[PHP RECOVERABLE ERROR]'; + case E_USER_NOTICE: + return '[ManiaControl NOTICE]'; + case E_USER_WARNING: + return '[ManiaControl WARNING]'; + case E_USER_ERROR: + return '[ManiaControl ERROR]'; + case self::MC_DEBUG_NOTICE: + return '[ManiaControl DEBUG]'; } - if ($errorLevel == E_WARNING) { - return '[PHP WARNING]'; - } - if ($errorLevel == E_ERROR) { - return '[PHP ERROR]'; - } - if ($errorLevel == E_CORE_ERROR) { - return '[PHP CORE ERROR]'; - } - if ($errorLevel == E_COMPILE_ERROR) { - return '[PHP COMPILE ERROR]'; - } - if ($errorLevel == E_RECOVERABLE_ERROR) { - return '[PHP RECOVERABLE ERROR]'; - } - if ($errorLevel == E_USER_NOTICE) { - return '[ManiaControl NOTICE]'; - } - if ($errorLevel == E_USER_WARNING) { - return '[ManiaControl WARNING]'; - } - if ($errorLevel == E_USER_ERROR) { - return '[ManiaControl ERROR]'; - } - if ($errorLevel == self::MC_DEBUG_NOTICE) { - return '[ManiaControl DEBUG]'; - } - return "[PHP {$errorLevel}]"; + return "[PHP ERROR '{$errorLevel}']"; } /** diff --git a/application/core/Maps/MapCommands.php b/application/core/Maps/MapCommands.php index 41bf4e37..70285ff4 100644 --- a/application/core/Maps/MapCommands.php +++ b/application/core/Maps/MapCommands.php @@ -472,7 +472,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb * @param Map $b * @return mixed */ - private function sortByKarma($a, $b) { + private function sortByKarma(Map $a, Map $b) { return ($a->karma - $b->karma); } } diff --git a/application/core/Maps/MapManager.php b/application/core/Maps/MapManager.php index 326ae9e9..e6496296 100644 --- a/application/core/Maps/MapManager.php +++ b/application/core/Maps/MapManager.php @@ -252,9 +252,9 @@ class MapManager implements CallbackListener { // Download the file $self->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$self, &$login, &$mapInfo, &$update) { - if (!$file) { + if (!$file || $error) { // Download error - $self->maniaControl->chat->sendError('Download failed!', $login); + $self->maniaControl->chat->sendError("Download failed: '{$error}'!", $login); return; } $self->processMapFile($file, $mapInfo, $login, $update); diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index eceec27b..c387f114 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -82,20 +82,19 @@ class MapQueue implements CallbackListener, CommandListener { /** * Clears the map-queue via admin command clearmap queue * - * @param array $chat - * @param \ManiaControl\Players\Player $admin - * @internal param \ManiaControl\Players\Player $player + * @param array $chatCallback + * @param Player $admin */ - public function command_ClearMapQueue(array $chat, Player $admin) { + public function command_ClearMapQueue(array $chatCallback, Player $admin) { $this->clearMapQueue($admin); } /** - * Clears the Map Queue + * Clear the Map Queue * - * @param $admin + * @param Player $admin */ - public function clearMapQueue($admin) { + public function clearMapQueue(Player $admin) { if (!$this->maniaControl->authenticationManager->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) { $this->maniaControl->authenticationManager->sendNotAllowed($admin); return; @@ -121,11 +120,11 @@ class MapQueue implements CallbackListener, CommandListener { /** * Handles the mapqueue/jukebox command * - * @param array $chat + * @param array $chatCallback * @param Player $player */ - public function command_MapQueue(array $chat, Player $player) { - $chatCommands = explode(' ', $chat[1][2]); + public function command_MapQueue(array $chatCallback, Player $player) { + $chatCommands = explode(' ', $chatCallback[1][2]); if (isset($chatCommands[1])) { if ($chatCommands[1] == ' ' || $chatCommands[1] == 'list') { @@ -143,9 +142,9 @@ class MapQueue implements CallbackListener, CommandListener { /** * Shows current mapqueue in the chat * - * @param $player + * @param Player $player */ - public function showMapQueue($player) { + public function showMapQueue(Player $player) { if (count($this->queuedMaps) == 0) { $this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login); return; @@ -164,9 +163,9 @@ class MapQueue implements CallbackListener, CommandListener { /** * Shows current mapqueue in a manialink * - * @param $player + * @param Player $player */ - public function showMapQueueManialink($player) { + public function showMapQueueManialink(Player $player) { if (count($this->queuedMaps) == 0) { $this->maniaControl->chat->sendError('$fa0There are no maps in the jukebox!', $player->login); return; @@ -192,10 +191,10 @@ class MapQueue implements CallbackListener, CommandListener { /** * Adds map as first map in queue (for /replay) * - * @param $player - * @param $map + * @param Player $player + * @param Map $map */ - public function addFirstMapToMapQueue($player, $map) { + public function addFirstMapToMapQueue(Player $player, Map $map) { if ($map) { if (array_key_exists($map->uid, $this->queuedMaps)) { unset($this->queuedMaps[$map->uid]); @@ -208,8 +207,8 @@ class MapQueue implements CallbackListener, CommandListener { /** * Adds a Map to the map-queue * - * @param $login - * @param $uid + * @param string $login + * @param string $uid */ public function addMapToMapQueue($login, $uid) { $player = $this->maniaControl->playerManager->getPlayer($login); @@ -270,9 +269,8 @@ class MapQueue implements CallbackListener, CommandListener { /** * Revmoes a Map from the Map queue * - * @param \ManiaControl\Players\Player $player - * @param $uid - * @internal param $login + * @param Player $player + * @param string $uid */ public function removeFromMapQueue(Player $player, $uid) { if (!isset($this->queuedMaps[$uid])) { @@ -355,7 +353,7 @@ class MapQueue implements CallbackListener, CommandListener { /** * Returns the next Map if the next map is a queuedmap or null if it's not * - * @return null + * @return Map */ public function getNextMap() { return $this->nextMap; diff --git a/application/core/Players/PlayerDetailed.php b/application/core/Players/PlayerDetailed.php index c0162271..f0dd4a13 100644 --- a/application/core/Players/PlayerDetailed.php +++ b/application/core/Players/PlayerDetailed.php @@ -14,7 +14,6 @@ use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Statistics\StatisticManager; -use Maniaplanet\DedicatedServer\Structures\Player; /** * Player Detailed Page diff --git a/application/core/Players/PlayerList.php b/application/core/Players/PlayerList.php index 1c5536e2..88ccc885 100644 --- a/application/core/Players/PlayerList.php +++ b/application/core/Players/PlayerList.php @@ -22,7 +22,6 @@ use ManiaControl\Formatter; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; -use Maniaplanet\DedicatedServer\Structures\Player; use Maniaplanet\DedicatedServer\Xmlrpc\LoginUnknownException; use Maniaplanet\DedicatedServer\Xmlrpc\PlayerIsNotSpectatorException; use MCTeam\CustomVotesPlugin; diff --git a/application/core/Plugins/PluginMenu.php b/application/core/Plugins/PluginMenu.php index 5b5d51f0..d6b64afd 100644 --- a/application/core/Plugins/PluginMenu.php +++ b/application/core/Plugins/PluginMenu.php @@ -245,6 +245,8 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $pluginUpdates = $this->maniaControl->updateManager->pluginUpdateManager->getPluginsUpdates(); usort($pluginClasses, function ($a, $b) { + /** @var Plugin $a */ + /** @var Plugin $b */ return strcmp($a::getName(), $b::getName()); }); diff --git a/application/core/Update/PluginUpdateManager.php b/application/core/Update/PluginUpdateManager.php index 68533960..2b2f62ee 100644 --- a/application/core/Update/PluginUpdateManager.php +++ b/application/core/Update/PluginUpdateManager.php @@ -242,6 +242,14 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) { $self = $this; $this->maniaControl->fileReader->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (&$self, &$pluginUpdateData, &$player, &$update) { + if (!$updateFileContent || $error) { + $message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!"; + if ($player) { + $self->maniaControl->chat->sendInformation($message, $player); + } + $self->maniaControl->log($message); + return; + } $actionNoun = ($update ? 'Update' : 'Install'); $actionVerb = ($update ? 'Updating' : 'Installing'); $actionVerbDone = ($update ? 'updated' : 'installed'); diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index 5266e263..bbecb460 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -303,6 +303,15 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $self = $this; $this->maniaControl->fileReader->loadFile($this->coreUpdateData->url, function ($updateFileContent, $error) use (&$self, &$updateData, &$player) { + if (!$updateFileContent || !$error) { + $message = "Update failed: Couldn't load Update zip!"; + if ($player) { + $self->maniaControl->chat->sendError($message, $player); + } + logMessage($message); + return; + } + $tempDir = FileUtil::getTempFolder(); $updateFileName = $tempDir . basename($updateData->url);