maniaplanet api update

This commit is contained in:
kremsy 2014-01-20 09:24:17 +01:00 committed by Steffen Schröder
parent 6520e75738
commit 7d8ba59771
6 changed files with 22 additions and 27 deletions

View File

@ -98,8 +98,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return false; return false;
} }
$serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
$serverSettings = (array)$this->maniaControl->client->getServerOptions();
$loadedSettings = array(); $loadedSettings = array();
while($row = $result->fetch_object()) { while($row = $result->fetch_object()) {
if(!isset($serverSettings[$row->settingName])) { if(!isset($serverSettings[$row->settingName])) {
@ -137,8 +137,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
$pagesId = 'ServerSettingsPages'; $pagesId = 'ServerSettingsPages';
$frame = new Frame(); $frame = new Frame();
//TODO temporary $serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
$serverSettings = $this->maniaControl->client->execute('GetServerOptions');
// Config // Config
$pagerSize = 9.; $pagerSize = 9.;
@ -268,8 +267,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return; return;
} }
// Note on ServerOptions the whole Options have to be saved, otherwise a error will appear $serverSettings = $this->maniaControl->client->getServerOptions()->toArray();
$serverSettings = $this->maniaControl->client->execute('GetServerOptions'); //TODO just temporary
$prefixLength = strlen(self::ACTION_PREFIX_SETTING); $prefixLength = strlen(self::ACTION_PREFIX_SETTING);
@ -361,6 +359,9 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' '; // $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
foreach($newSettings as $setting => $value) { foreach($newSettings as $setting => $value) {
if($value == null) {
continue;
}
$statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value); $statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
$statement->execute(); $statement->execute();
if($statement->error) { if($statement->error) {
@ -393,16 +394,4 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return true; return true;
} }
/**
* Parse the Setting Value to a String Representation
*
* @param mixed $value
* @return string
*/
private function parseSettingValue($value) {
if(is_bool($value)) {
return ($value ? 'True' : 'False');
}
return (string)$value;
}
} }

View File

@ -106,8 +106,8 @@ class Connection
* @param string $authLevel * @param string $authLevel
* @param array $params * @param array $params
*/ */
public function execute($methodName, $params = array(), $multicall = false) protected function execute($methodName, $params = array(), $multicall = false)
{//TODO just temporary {
if($multicall) if($multicall)
{ {
$this->xmlrpcClient->addCall($methodName, $params); $this->xmlrpcClient->addCall($methodName, $params);

View File

@ -15,6 +15,7 @@ class ScriptInfo extends AbstractStructure
public $description; public $description;
public $version; public $version;
public $paramDescs = array(); public $paramDescs = array();
public $commandDescs = array();
static public function fromArray($array) static public function fromArray($array)
{ {
@ -24,6 +25,10 @@ class ScriptInfo extends AbstractStructure
{ {
$object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs); $object->paramDescs = ScriptSettings::fromArrayOfArray($object->paramDescs);
} }
if($object->commandDescs)
{
$object->commandDescs = Command::fromArrayOfArray($object->commandDescs);
}
return $object; return $object;
} }

View File

@ -4,7 +4,7 @@
* *
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3 * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
*/ */
namespace Maniaplanet\DedicatedServer\Structures; namespace Maniaplanet\DedicatedServer\Structures;
class ServerOptions extends AbstractStructure class ServerOptions extends AbstractStructure
@ -39,4 +39,6 @@ class ServerOptions extends AbstractStructure
public $nextUseChangingValidationSeed; public $nextUseChangingValidationSeed;
public $clientInputsMaxLatency; public $clientInputsMaxLatency;
public $keepPlayerSlots; public $keepPlayerSlots;
public $disableHorns;
public $disableServiceAnnounces;
} }

View File

@ -67,13 +67,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
$scriptInfos = $this->maniaControl->client->getModeScriptInfo(); $scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$pauseExists = false; $pauseExists = false;
/*foreach($scriptInfos['commandDescs'] as $param) { foreach($scriptInfos->commandDescs as $param) {
if($param['Name'] == "Command_ForceWarmUp") { if($param->name == "Command_ForceWarmUp") {
$pauseExists = true; $pauseExists = true;
break; break;
} }
}*/ //TODO temp }
$pauseExists = true;
// Set Pause // Set Pause
if($pauseExists) { if($pauseExists) {

View File

@ -197,11 +197,11 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
$this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map'); $this->addVoteMenuItem($itemQuad, 5, 'Vote for Restart-Map');
//Check if Pause exists in current gamemode //Check if Pause exists in current gamemode
$scriptInfos = (array)$this->maniaControl->client->getModeScriptInfo(); $scriptInfos = $this->maniaControl->client->getModeScriptInfo();
$pauseExists = false; $pauseExists = false;
foreach($scriptInfos["commandDescs"] as $param) { foreach($scriptInfos->commandDescs as $param) {
if($param['Name'] == "Command_ForceWarmUp") { if($param->name == "Command_ForceWarmUp") {
$pauseExists = true; $pauseExists = true;
break; break;
} }