From 63981d8002dbdc4e84279926306a0fb069280c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Tue, 20 May 2014 15:42:10 +0200 Subject: [PATCH] - adjustment for dedicated-api update - minor changes --- .../core/Configurators/ServerSettings.php | 30 ++++++++----------- application/core/Maps/MapQueue.php | 2 +- application/core/Players/PlayerActions.php | 6 ++-- application/core/Players/PlayerCommands.php | 2 +- application/plugins/MCTeam/KarmaPlugin.php | 2 +- 5 files changed, 18 insertions(+), 24 deletions(-) diff --git a/application/core/Configurators/ServerSettings.php b/application/core/Configurators/ServerSettings.php index 90c3b83d..370e8a2c 100644 --- a/application/core/Configurators/ServerSettings.php +++ b/application/core/Configurators/ServerSettings.php @@ -17,6 +17,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +use Maniaplanet\DedicatedServer\Structures\ServerOptions; use Maniaplanet\DedicatedServer\Xmlrpc\ServerOptionsException; /** @@ -107,15 +108,16 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { trigger_error($mysqli->error); return false; } - $serverSettings = $this->maniaControl->client->getServerOptions()->toArray(); + $serverSettings = $this->maniaControl->client->getServerOptions(); $applySettings = false; while ($row = $result->fetch_object()) { - if (!isset($serverSettings[$row->settingName])) { + $settingName = $row->settingName; + if (!property_exists($serverSettings, $settingName)) { continue; } - $oldType = gettype($serverSettings[$row->settingName]); - $serverSettings[$row->settingName] = $row->settingValue; - settype($serverSettings[$row->settingName], $oldType); + $oldType = gettype($serverSettings->$settingName); + $serverSettings->$settingName = $row->settingValue; + settype($serverSettings->$settingName, $oldType); $applySettings = true; } $result->free(); @@ -278,24 +280,15 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { /** * Apply the Array of new Server Settings * - * @param array $newSettings - * @param Player $player + * @param ServerOptions $newSettings + * @param Player $player * @return bool */ - private function applyNewServerSettings(array $newSettings, Player $player) { + private function applyNewServerSettings(ServerOptions $newSettings, Player $player) { if (!$newSettings) { return true; } - $rewriteSettings = array('NextUseChangingValidationSeed' => 'UseChangingValidationSeed'); - foreach ($rewriteSettings as $oldName => $newName) { - if (array_key_exists($oldName, $newSettings)) { - $setting = $newSettings[$oldName]; - unset($newSettings[$oldName]); - $newSettings[$newName] = $setting; - } - } - try { $this->maniaControl->client->setServerOptions($newSettings); } catch (ServerOptionsException $e) { @@ -320,7 +313,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener { return false; } - foreach ($newSettings as $setting => $value) { + $settingsArray = $newSettings->toArray(); + foreach ($settingsArray as $setting => $value) { if ($value === null) { continue; } diff --git a/application/core/Maps/MapQueue.php b/application/core/Maps/MapQueue.php index 450e98ec..097b224d 100644 --- a/application/core/Maps/MapQueue.php +++ b/application/core/Maps/MapQueue.php @@ -89,7 +89,7 @@ class MapQueue implements CallbackListener, CommandListener { } /** - * Clears the map-queue via admin command clearmap queue + * Clears the map-queue via admin command clear map queue * * @param array $chatCallback * @param Player $admin diff --git a/application/core/Players/PlayerActions.php b/application/core/Players/PlayerActions.php index d3cca81b..7db40c0c 100644 --- a/application/core/Players/PlayerActions.php +++ b/application/core/Players/PlayerActions.php @@ -137,8 +137,8 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_PLAYER); } catch (FaultException $e) { - //TODO exception 'There are too many players' appeared 28.04.2014, wait for more before add to faultexception - $this->maniaControl->chat->sendException($e, $admin->login); + //TODO exception 'There are too many players' appeared 28.04.2014, wait for more before add to fault exception + $this->maniaControl->chat->sendException($e, $admin); return; } @@ -146,7 +146,7 @@ class PlayerActions { try { $this->maniaControl->client->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE); } catch (Exception $e) { - $this->maniaControl->chat->sendException($e, $admin->login); + $this->maniaControl->chat->sendException($e, $admin); return; } } diff --git a/application/core/Players/PlayerCommands.php b/application/core/Players/PlayerCommands.php index 7e63a0fb..785a565e 100644 --- a/application/core/Players/PlayerCommands.php +++ b/application/core/Players/PlayerCommands.php @@ -52,7 +52,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca $this->maniaControl->commandManager->registerCommandListener(array('addbots', 'addbot'), $this, 'command_AddFakePlayers', true, 'Adds bots to the game.'); $this->maniaControl->commandManager->registerCommandListener(array('removebot', 'removebots'), $this, 'command_RemoveFakePlayers', true, 'Removes bots from the game.'); $this->maniaControl->commandManager->registerCommandListener('mute', $this, 'command_MutePlayer', true, 'Mutes a player (prevents player from chatting).'); - $this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmutes a player (enables player to chat again).'); + $this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmute a player (enables player to chat again).'); // Register for player chat commands $this->maniaControl->commandManager->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.'); diff --git a/application/plugins/MCTeam/KarmaPlugin.php b/application/plugins/MCTeam/KarmaPlugin.php index 09da9e50..a368e59c 100644 --- a/application/plugins/MCTeam/KarmaPlugin.php +++ b/application/plugins/MCTeam/KarmaPlugin.php @@ -55,7 +55,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { */ const SETTING_WIDGET_DISPLAY_MX = 'Display MX-Karma in Widget'; const SETTING_MX_KARMA_ACTIVATED = 'Activate MX-Karma'; - const SETTING_MX_KARMA_IMPORTING = 'Import old MX-Karmas'; + const SETTING_MX_KARMA_IMPORTING = 'Import old MX-Karma'; const MX_IMPORT_TABLE = 'mc_karma_mximport'; const MX_KARMA_URL = 'http://karma.mania-exchange.com/api2/'; const MX_KARMA_STARTSESSION = 'startSession';