diff --git a/application/core/Callbacks/CallbackManager.php b/application/core/Callbacks/CallbackManager.php index f3868616..a9dff30d 100644 --- a/application/core/Callbacks/CallbackManager.php +++ b/application/core/Callbacks/CallbackManager.php @@ -213,8 +213,8 @@ class CallbackManager { case 'ManiaPlanet.BeginMatch': if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $this->triggerCallback($callbackName, $callback); - break; } + break; case 'ManiaPlanet.BeginMap': $this->maniaControl->mapManager->handleBeginMap($callback); $this->triggerCallback($callbackName, $callback); @@ -222,8 +222,8 @@ class CallbackManager { case 'ManiaPlanet.EndMatch': // TODO temporary fix if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { $this->triggerCallback($callbackName, $callback); - break; } + break; case 'ManiaPlanet.EndMap': $this->maniaControl->mapManager->handleEndMap($callback); $this->triggerCallback($callbackName, $callback); diff --git a/application/core/Callbacks/Callbacks.php b/application/core/Callbacks/Callbacks.php index 2792223e..b46bbffd 100644 --- a/application/core/Callbacks/Callbacks.php +++ b/application/core/Callbacks/Callbacks.php @@ -45,13 +45,13 @@ interface Callbacks { * param4 int AFKStatus */ const PLAYERRANKING = 'Callbacks.PlayerRanking'; - //Shootmania Callbacks + //ShootMania Callbacks /** RankingsUpdated Callback, param1 Sorted Rankings */ const RANKINGSUPDATED = 'Callbacks.RankingsUpdated'; /** RankingsUpdated Callback, returned after LibXmlRpc_PlayerRanking param1 Scores */ const SCORES = 'Callbacks.Scores'; /** Returns the AFKStatus of an Player, returned after param1 Scores */ //returned after TODO const AFKSTATUS = 'Callbacks.AfkStatus'; - /** Returns if the GameMode has Warmup aktivated, returned after param1 Scores */ //returned after TODO + /** Returns if the GameMode has Warmup activated, returned after param1 Scores */ //returned after TODO const WARMUPSTATUS = 'Callbacks.WarmupStatus'; } \ No newline at end of file diff --git a/application/core/Configurators/Configurator.php b/application/core/Configurators/Configurator.php index e05cb09c..fd369691 100644 --- a/application/core/Configurators/Configurator.php +++ b/application/core/Configurators/Configurator.php @@ -100,7 +100,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn } /** - * Handle Config Admin Aommand + * Handle Config Admin Command * * @param array $callback */ diff --git a/application/core/Configurators/ManiaControlSettings.php b/application/core/Configurators/ManiaControlSettings.php index 582f08d7..37699fe8 100644 --- a/application/core/Configurators/ManiaControlSettings.php +++ b/application/core/Configurators/ManiaControlSettings.php @@ -111,7 +111,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $y = 0; $index = 1; $prevClass = ''; - foreach($settings as $id => $setting) { + foreach($settings as $setting) { //Don't display Plugin Settings if (array_search($setting->class, $pluginClasses) !== FALSE) { continue; diff --git a/application/core/Configurators/ScriptSettings.php b/application/core/Configurators/ScriptSettings.php index 0422f310..411124a1 100644 --- a/application/core/Configurators/ScriptSettings.php +++ b/application/core/Configurators/ScriptSettings.php @@ -373,7 +373,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener { } /** - * Toogle a Boolean Setting + * Toggle a Boolean Setting * * @param Player $player * @param $setting diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index a78fb60d..0f20f122 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -383,7 +383,7 @@ class ManiaControl implements CommandListener, TimerListener { */ private function connect() { // Load remote client - $success = $this->server->loadConfig(); + $this->server->loadConfig(); $this->log("Connecting to server at {$this->server->config->host}:{$this->server->config->port}..."); diff --git a/application/core/ManiaExchange/ManiaExchangeList.php b/application/core/ManiaExchange/ManiaExchangeList.php index 252f91c3..4376e3ea 100644 --- a/application/core/ManiaExchange/ManiaExchangeList.php +++ b/application/core/ManiaExchange/ManiaExchangeList.php @@ -24,7 +24,6 @@ use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Maps\MapCommands; use ManiaControl\Maps\MapManager; -use ManiaControl\Maps\MapQueue; use ManiaControl\Players\Player; /** diff --git a/application/core/ManiaExchange/ManiaExchangeManager.php b/application/core/ManiaExchange/ManiaExchangeManager.php index c8137596..1b517e1c 100644 --- a/application/core/ManiaExchange/ManiaExchangeManager.php +++ b/application/core/ManiaExchange/ManiaExchangeManager.php @@ -360,7 +360,7 @@ class ManiaExchangeManager{ } /** - * Gets the Current Environemnt by String + * Gets the Current Environment by String * * @param $env * @return int diff --git a/application/core/Manialinks/ManialinkManager.php b/application/core/Manialinks/ManialinkManager.php index 28bd0b0d..9d1d2925 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; use Maniaplanet\DedicatedServer\Xmlrpc\LoginUnknownException; use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException; diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index 4162f0c9..e58fd489 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -4,7 +4,6 @@ namespace ManiaControl\Maps; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; -use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Commands\CommandListener; use ManiaControl\Formatter; use ManiaControl\ManiaControl; diff --git a/application/core/Players/PlayerManager.php b/application/core/Players/PlayerManager.php index 7c155563..7eb1181b 100644 --- a/application/core/Players/PlayerManager.php +++ b/application/core/Players/PlayerManager.php @@ -377,7 +377,7 @@ class PlayerManager implements CallbackListener, TimerListener { return null; } - $player = new Player(false); + $player = new Player(null); $player->index = $playerIndex; $player->login = $row->login; $player->rawNickname = $row->nickname; @@ -412,7 +412,7 @@ class PlayerManager implements CallbackListener, TimerListener { return null; } - $player = new Player(false); + $player = new Player(null); $player->index = $row->index; $player->login = $row->login; $player->rawNickname = $row->nickname; diff --git a/application/core/Plugins/PluginManager.php b/application/core/Plugins/PluginManager.php index 9fcc45db..ba82540f 100644 --- a/application/core/Plugins/PluginManager.php +++ b/application/core/Plugins/PluginManager.php @@ -76,9 +76,7 @@ class PluginManager { * @return bool */ public function isPluginActive($pluginClass) { - if (is_object($pluginClass)) { - $pluginClass = get_class($pluginClass); - } + $pluginClass = $this->getPluginClass($pluginClass); return isset($this->activePlugins[$pluginClass]); } @@ -89,9 +87,7 @@ class PluginManager { * @return bool */ public function isPluginClass($pluginClass) { - if (is_object($pluginClass)) { - $pluginClass = get_class($pluginClass); - } + $pluginClass = $this->getPluginClass($pluginClass); if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($pluginClass))) { return false; } @@ -105,9 +101,7 @@ class PluginManager { * @return bool */ public function addPluginClass($pluginClass) { - if (is_object($pluginClass)) { - $pluginClass = get_class($pluginClass); - } + $pluginClass = $this->getPluginClass($pluginClass); if (in_array($pluginClass, $this->pluginClasses)) { return false; } @@ -161,9 +155,7 @@ class PluginManager { * @return bool */ public function deactivatePlugin($pluginClass) { - if (is_object($pluginClass)) { - $pluginClass = get_class($pluginClass); - } + $pluginClass = $this->getPluginClass($pluginClass); if (!$this->isPluginActive($pluginClass)) { return false; } @@ -171,12 +163,11 @@ class PluginManager { /** @var Plugin $plugin */ unset($this->activePlugins[$pluginClass]); $plugin->unload(); - $interfaces = class_implements($pluginClass); - if (in_array(CallbackListener::CALLBACKLISTENER_INTERFACE, $interfaces)) { + if ($plugin instanceof CallbackListener) { $this->maniaControl->callbackManager->unregisterCallbackListener($plugin); $this->maniaControl->callbackManager->unregisterScriptCallbackListener($plugin); } - if (in_array(ManialinkPageAnswerListener::MANIALINKPAGEANSWERLISTENER_INTERFACE, $interfaces)) { + if ($plugin instanceof ManialinkPageAnswerListener) { $this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($plugin); } $this->savePluginStatus($pluginClass, false); @@ -357,4 +348,17 @@ class PluginManager { call_user_func($function, $data, $error); }); } + + /** + * Get the Class of the Plugin + * + * @param mixed $pluginClass + * @return string + */ + private function getPluginClass($pluginClass) { + if (is_object($pluginClass)) { + $pluginClass = get_class($pluginClass); + } + return (string) $pluginClass; + } } diff --git a/application/core/Update/PluginInstallMenu.php b/application/core/Update/PluginInstallMenu.php index 49ff69be..fbe65207 100644 --- a/application/core/Update/PluginInstallMenu.php +++ b/application/core/Update/PluginInstallMenu.php @@ -3,20 +3,15 @@ namespace ManiaControl\Update; use FML\Controls\Control; -use FML\Controls\Entry; use FML\Controls\Frame; use FML\Controls\Label; use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Text; -use FML\Controls\Quads\Quad_Icons128x32_1; -use FML\Controls\Quads\Quad_Icons128x128_1; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Script\Script; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; -use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Configurators\ConfiguratorMenu; -use ManiaControl\Formatter; use ManiaControl\Files\FileUtil; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; @@ -65,8 +60,6 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink $pagesId = 'PluginInstallPages'; $frame = new Frame(); - $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); - // Config $pagerSize = 9.; $entryHeight = 5.; @@ -105,7 +98,7 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink $pluginList = json_decode($dataJson); $index = 0; if ($pluginList && isset($pluginList[0])) { - $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); + $pluginClasses = $this->maniaControl->pluginManager->getPluginClasses(); $pluginIds = array(); /** @var Plugin $class */ foreach($pluginClasses as $class) { diff --git a/application/core/Update/UpdateManager.php b/application/core/Update/UpdateManager.php index 980a99a2..a71ab423 100644 --- a/application/core/Update/UpdateManager.php +++ b/application/core/Update/UpdateManager.php @@ -501,18 +501,18 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener if (!$bytes || $bytes <= 0) { trigger_error("Couldn't save plugin Zip."); if ($player) { - $self->maniaControl->chat->sendError('Update failed: Couldn\'t save plugin zip!', $player->login); + $self->maniaControl->chat->sendError("Update failed: Couldn't save plugin zip!", $player->login); } - return false; + return; } $zip = new \ZipArchive(); $result = $zip->open($updateFileName); if ($result !== true) { trigger_error("Couldn't open plugin Zip. ({$result})"); if ($player) { - $self->maniaControl->chat->sendError('Update failed: Couldn\'t open plugin zip!', $player->login); + $self->maniaControl->chat->sendError("Update failed: Couldn't open plugin zip!", $player->login); } - return false; + return; } $zip->extractTo(ManiaControlDir . '/plugins'); @@ -559,15 +559,15 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener $bytes = file_put_contents($installFileName, $installFileContent); if (!$bytes || $bytes <= 0) { trigger_error("Couldn't save plugin Zip."); - $self->maniaControl->chat->sendError('Install failed: Couldn\'t save plugin zip!', $player->login); - return false; + $self->maniaControl->chat->sendError("Install failed: Couldn't save plugin zip!", $player->login); + return; } $zip = new \ZipArchive(); $result = $zip->open($installFileName); if ($result !== true) { trigger_error("Couldn't open plugin Zip. ({$result})"); - $self->maniaControl->chat->sendError('Install failed: Couldn\'t open plugin zip!', $player->login); - return false; + $self->maniaControl->chat->sendError("Install failed: Couldn't open plugin zip!", $player->login); + return; } $zip->extractTo(ManiaControlDir . '/plugins'); @@ -782,7 +782,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener if (!$bytes || $bytes <= 0) { trigger_error("Couldn't save Update Zip."); if ($player) { - $self->maniaControl->chat->sendError('Update failed: Couldn\'t save Update zip!', $player->login); + $self->maniaControl->chat->sendError("Update failed: Couldn't save Update zip!", $player->login); } return false; } @@ -791,7 +791,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener if ($result !== true) { trigger_error("Couldn't open Update Zip. ({$result})"); if ($player) { - $self->maniaControl->chat->sendError('Update failed: Couldn\'t open Update zip!', $player->login); + $self->maniaControl->chat->sendError("Update failed: Couldn't open Update zip!", $player->login); } return false; } diff --git a/application/plugins/Dedimania/Dedimania.php b/application/plugins/Dedimania/Dedimania.php index 0b64e8ae..9e7d24c7 100644 --- a/application/plugins/Dedimania/Dedimania.php +++ b/application/plugins/Dedimania/Dedimania.php @@ -967,6 +967,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu } else if ($scriptName == 'TimeAttack' || $scriptName == 'Laps' || $scriptName == 'TeamAttack' || $scriptName == 'TimeAttackPlus') { return 'TA'; } + break; } case 1: case 3: diff --git a/application/plugins/Karma.php b/application/plugins/Karma.php index ff9fa734..2f671cb5 100644 --- a/application/plugins/Karma.php +++ b/application/plugins/Karma.php @@ -218,7 +218,6 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $karmaGauge->setColor($karmaColor . '7'); $karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $voteCount . ')'); } else { - $karma = 0.; $karmaGauge->setRatio(0.); $karmaGauge->setColor('00fb'); $karmaLabel->setText('-'); @@ -227,7 +226,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { // Loop players foreach($players as $login => $player) { // Get player vote - //$vote = $this->getPlayerVote($player, $map); //TODO what is this for, vote nowhere used? + // TODO: show the player his own vote in some way + //$vote = $this->getPlayerVote($player, $map); // Adjust manialink for player's vote $votesFrame = $this->manialink->votesFrame; diff --git a/application/plugins/LocalRecords.php b/application/plugins/LocalRecords.php index 89da3a76..ca38044d 100644 --- a/application/plugins/LocalRecords.php +++ b/application/plugins/LocalRecords.php @@ -359,9 +359,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } $mysqli = $this->maniaControl->database->mysqli; - $removeRecord = $records[$recordId-1]; $query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = ".$currentMap->index." AND `playerIndex` = ".$player->index.""; - $result = $mysqli->query($query); + $mysqli->query($query); if ($mysqli->error) { trigger_error($mysqli->error); return null; diff --git a/application/plugins/QueuePlugin.php b/application/plugins/QueuePlugin.php index a681b707..e33a7eac 100644 --- a/application/plugins/QueuePlugin.php +++ b/application/plugins/QueuePlugin.php @@ -366,7 +366,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns * @return bool */ private function addPlayerToQueue(Player $player) { - if($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) return; + if($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) return false; foreach($this->queue as $queuedPlayer) { if($queuedPlayer->login == $player->login) { @@ -379,6 +379,8 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns $this->queue[count($this->queue)] = $player; $this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!'); } + + return true; } /** diff --git a/application/plugins/TeamSpeakPlugin.php b/application/plugins/TeamSpeakPlugin.php index c24149c5..7bd09dcd 100644 --- a/application/plugins/TeamSpeakPlugin.php +++ b/application/plugins/TeamSpeakPlugin.php @@ -319,7 +319,6 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag $frame->add($users[$userid]); $y = 17.5 + ($i * 2.5); $users[$userid]->setY($height / 2 - $y); - $x = $startx; if ($channel['pid'] != 0) { $x = $startx + 7; } else {