- adjustment for dedicated-api update

- minor changes
This commit is contained in:
Steffen Schröder 2014-05-20 15:42:10 +02:00
parent 18cd71818a
commit 63981d8002
5 changed files with 18 additions and 24 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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.');

View File

@ -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';