removed old php 5.3 compatibility code
This commit is contained in:
@ -263,36 +263,35 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $mapInfo, $gameMode, $serverInfo, $playerInfo);
|
||||
$content = $this->encode_request(self::DEDIMANIA_GETRECORDS, $data);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
$self->maniaControl->log('Dedimania Error: ' . $error);
|
||||
$this->maniaControl->log('Dedimania Error: ' . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GETRECORDS);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_GETRECORDS);
|
||||
return;
|
||||
}
|
||||
|
||||
$responseData = $methodResponse[0];
|
||||
$self->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank'];
|
||||
$this->dedimaniaData->serverMaxRank = $responseData['ServerMaxRank'];
|
||||
|
||||
foreach ($responseData['Players'] as $player) {
|
||||
$dediPlayer = new DedimaniaPlayer($player);
|
||||
$self->dedimaniaData->addPlayer($dediPlayer);
|
||||
$this->dedimaniaData->addPlayer($dediPlayer);
|
||||
}
|
||||
foreach ($responseData['Records'] as $key => $record) {
|
||||
$self->dedimaniaData->records[$key] = new RecordData($record);
|
||||
$this->dedimaniaData->records[$key] = new RecordData($record);
|
||||
}
|
||||
|
||||
$self->updateManialink = true;
|
||||
$self->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $self->dedimaniaData->records);
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_DEDIMANIA_UPDATED, $this->dedimaniaData->records);
|
||||
}, $content, true);
|
||||
|
||||
return true;
|
||||
@ -528,27 +527,26 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
|
||||
$content = $this->encode_request(self::DEDIMANIA_CHECKSESSION, array($this->dedimaniaData->sessionId));
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECKSESSION);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_CHECKSESSION);
|
||||
return;
|
||||
}
|
||||
|
||||
$responseData = $methodResponse[0];
|
||||
if (is_bool($responseData)) {
|
||||
if (!$responseData) {
|
||||
$self->openDedimaniaSession();
|
||||
$this->openDedimaniaSession();
|
||||
}
|
||||
}
|
||||
}, $content, true);
|
||||
@ -565,35 +563,34 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, $player->rawNickname, $player->path, $player->isSpectator);
|
||||
$content = $this->encode_request(self::DEDIMANIA_PLAYERCONNECT, $data);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self, &$player) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$player) {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERCONNECT);
|
||||
return;
|
||||
}
|
||||
|
||||
$responseData = $methodResponse[0];
|
||||
$dediPlayer = new DedimaniaPlayer($responseData);
|
||||
$self->dedimaniaData->addPlayer($dediPlayer);
|
||||
$this->dedimaniaData->addPlayer($dediPlayer);
|
||||
|
||||
// Fetch records if he is the first who joined the server
|
||||
if ($self->maniaControl->playerManager->getPlayerCount(false) === 1) {
|
||||
$self->fetchDedimaniaRecords(true);
|
||||
if ($this->maniaControl->playerManager->getPlayerCount(false) === 1) {
|
||||
$this->fetchDedimaniaRecords(true);
|
||||
}
|
||||
|
||||
if ($self->maniaControl->settingManager->getSettingValue($self, self::SETTING_WIDGET_ENABLE)) {
|
||||
$manialink = $self->buildManialink();
|
||||
$self->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
$manialink = $this->buildManialink();
|
||||
$this->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}, $content, true);
|
||||
}
|
||||
@ -613,20 +610,19 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $player->login, '');
|
||||
$content = $this->encode_request(self::DEDIMANIA_PLAYERDISCONNECT, $data);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_PLAYERDISCONNECT);
|
||||
}
|
||||
}, $content, true);
|
||||
}
|
||||
@ -681,21 +677,19 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
//var_dump($data);
|
||||
$content = $this->encode_request(self::DEDIMANIA_SETCHALLENGETIMES, $data);
|
||||
|
||||
$self = $this;
|
||||
$maniaControl = $this->maniaControl;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self, &$maniaControl) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
$maniaControl->log("Dedimania Error: " . $error);
|
||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SETCHALLENGETIMES);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_SETCHALLENGETIMES);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -721,20 +715,19 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
$data = array($this->dedimaniaData->sessionId, $serverInfo, $votesInfo, $playerList);
|
||||
$content = $this->encode_request(self::DEDIMANIA_UPDATESERVERPLAYERS, $data);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) use (&$self) {
|
||||
$this->maniaControl->fileReader->postData(self::DEDIMANIA_URL, function ($data, $error) {
|
||||
if ($error) {
|
||||
$self->maniaControl->log("Dedimania Error: " . $error);
|
||||
$this->maniaControl->log("Dedimania Error: " . $error);
|
||||
}
|
||||
|
||||
$data = $self->decode($data);
|
||||
$data = $this->decode($data);
|
||||
if (!is_array($data) || empty($data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$methodResponse = $data[0];
|
||||
if (xmlrpc_is_fault($methodResponse)) {
|
||||
$self->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATESERVERPLAYERS);
|
||||
$this->handleXmlRpcFault($methodResponse, self::DEDIMANIA_UPDATESERVERPLAYERS);
|
||||
}
|
||||
}, $content, true);
|
||||
}
|
||||
|
@ -282,31 +282,30 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
}
|
||||
|
||||
//Send and Handle the Bill
|
||||
$self = $this;
|
||||
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||
$this->maniaControl->billManager->sendBill(function ($data, $status) use (&$player, $amount, $receiver) {
|
||||
switch ($status) {
|
||||
case BillManager::DONATED_TO_SERVER:
|
||||
if ($self->maniaControl->settingManager->getSettingValue($self, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $self->maniaControl->settingManager->getSettingValue($self, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, DonationPlugin::SETTING_ANNOUNCE_SERVERDONATION, true) && $amount >= $this->maniaControl->settingManager->getSettingValue($this, DonationPlugin::SETTING_MIN_AMOUNT_SHOWN, true)) {
|
||||
$login = null;
|
||||
$message = '$<' . $player->nickname . '$> donated ' . $amount . ' Planets! Thanks.';
|
||||
} else {
|
||||
$login = $player->login;
|
||||
$message = 'Donation successful! Thanks.';
|
||||
}
|
||||
$self->maniaControl->chat->sendSuccess($message, $login);
|
||||
$self->maniaControl->statisticManager->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $self->maniaControl->server->index, $amount);
|
||||
$this->maniaControl->chat->sendSuccess($message, $login);
|
||||
$this->maniaControl->statisticManager->insertStat(DonationPlugin::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->index, $amount);
|
||||
break;
|
||||
case BillManager::DONATED_TO_RECEIVER:
|
||||
$message = "Successfully donated {$amount} to '{$receiver}'!";
|
||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
$this->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
break;
|
||||
case BillManager::PLAYER_REFUSED_DONATION:
|
||||
$message = 'Transaction cancelled.';
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
case BillManager::ERROR_WHILE_TRANSACTION:
|
||||
$message = $data;
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
}
|
||||
}, $player, $amount, $message);
|
||||
@ -393,20 +392,19 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
}
|
||||
$message = 'Payout from $<' . $this->maniaControl->client->getServerName() . '$>.';
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$self, &$player, $amount, $receiver) {
|
||||
$this->maniaControl->billManager->sendPlanets(function ($data, $status) use (&$player, $amount, $receiver) {
|
||||
switch ($status) {
|
||||
case BillManager::PAYED_FROM_SERVER:
|
||||
$message = "Successfully payed out {$amount} to '{$receiver}'!";
|
||||
$self->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
$this->maniaControl->chat->sendSuccess($message, $player->login);
|
||||
break;
|
||||
case BillManager::PLAYER_REFUSED_DONATION:
|
||||
$message = 'Transaction cancelled.';
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
case BillManager::ERROR_WHILE_TRANSACTION:
|
||||
$message = $data;
|
||||
$self->maniaControl->chat->sendError($message, $player->login);
|
||||
$this->maniaControl->chat->sendError($message, $player->login);
|
||||
break;
|
||||
}
|
||||
}, $receiver, $amount, $message);
|
||||
|
@ -253,24 +253,23 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$this->mxKarma['connectionInProgress'] = true;
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use (&$self, $mxKarmaCode) {
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($mxKarmaCode) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
$self->mxKarma['session'] = $data->data;
|
||||
$self->activateSession($mxKarmaCode);
|
||||
$this->mxKarma['session'] = $data->data;
|
||||
$this->activateSession($mxKarmaCode);
|
||||
} else {
|
||||
$self->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
} else {
|
||||
$self->maniaControl->log($error);
|
||||
$this->maniaControl->log($error);
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000);
|
||||
}
|
||||
@ -288,33 +287,32 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey);
|
||||
$query .= '&activationHash=' . urlencode($hash);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use (&$self, $query) {
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($data, $error) use ($query) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success && $data->data->activated) {
|
||||
$self->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
$this->maniaControl->log("Successfully authenticated on Mania-Exchange Karma");
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
|
||||
// Fetch the Mx Karma Votes
|
||||
$self->getMxKarmaVotes();
|
||||
$this->getMxKarmaVotes();
|
||||
} else {
|
||||
if ($data->data->message === "invalid hash") {
|
||||
$permission = $self->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||
$self->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
||||
$permission = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||
$this->maniaControl->chat->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
||||
} else {
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while authenticating on Mania-Exchange Karma " . $data->data->message . " url Query " . $query);
|
||||
}
|
||||
$self->maniaControl->log("Error while activating Mania-Exchange Karma Session: " . $data->data->message);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
unset($self->mxKarma['session']);
|
||||
$this->maniaControl->log("Error while activating Mania-Exchange Karma Session: " . $data->data->message);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
unset($this->mxKarma['session']);
|
||||
}
|
||||
} else {
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while activating Mania-Exchange Karma Session: " . $error);
|
||||
$self->maniaControl->log($error);
|
||||
$self->mxKarma['connectionInProgress'] = false;
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while activating Mania-Exchange Karma Session: " . $error);
|
||||
$this->maniaControl->log($error);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000);
|
||||
}
|
||||
@ -372,38 +370,37 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
$content = json_encode($properties);
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_GETMAPRATING . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use (&$self, &$player) {
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_GETMAPRATING . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use (&$player) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
|
||||
// Fetch averages if its for the whole server
|
||||
if (!$player) {
|
||||
$self->mxKarma["voteCount"] = $data->data->votecount;
|
||||
$self->mxKarma["voteAverage"] = $data->data->voteaverage;
|
||||
$self->mxKarma["modeVoteCount"] = $data->data->modevotecount;
|
||||
$self->mxKarma["modeVoteAverage"] = $data->data->modevoteaverage;
|
||||
$this->mxKarma["voteCount"] = $data->data->votecount;
|
||||
$this->mxKarma["voteAverage"] = $data->data->voteaverage;
|
||||
$this->mxKarma["modeVoteCount"] = $data->data->modevotecount;
|
||||
$this->mxKarma["modeVoteAverage"] = $data->data->modevoteaverage;
|
||||
}
|
||||
|
||||
foreach ($data->data->votes as $votes) {
|
||||
$self->mxKarma["votes"][$votes->login] = $votes->vote;
|
||||
$this->mxKarma["votes"][$votes->login] = $votes->vote;
|
||||
}
|
||||
|
||||
$self->updateManialink = true;
|
||||
$self->maniaControl->callbackManager->triggerCallback($self::CB_KARMA_MXUPDATED, $self->mxKarma);
|
||||
$self->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma);
|
||||
$this->maniaControl->log("MX-Karma Votes successfully fetched");
|
||||
} else {
|
||||
$self->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
||||
$this->maniaControl->log("Error while fetching votes: " . $data->data->message);
|
||||
if ($data->data->message === 'invalid session') {
|
||||
unset($this->mxKarma['session']);
|
||||
return;
|
||||
}
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: '{$data->data->message}' " . KarmaPlugin::MX_KARMA_URL . KarmaPlugin::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey));
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while fetching votes: '{$data->data->message}' " . KarmaPlugin::MX_KARMA_URL . KarmaPlugin::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey));
|
||||
}
|
||||
} else {
|
||||
$self->maniaControl->log($error);
|
||||
$this->maniaControl->log($error);
|
||||
}
|
||||
}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
}
|
||||
@ -482,23 +479,22 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$content = json_encode($properties);
|
||||
|
||||
$self = $this;
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) use (&$self) {
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($data, $error) {
|
||||
if (!$error) {
|
||||
$data = json_decode($data);
|
||||
if ($data->success) {
|
||||
$self->maniaControl->log("Votes successfully submitted");
|
||||
$this->maniaControl->log("Votes successfully submitted");
|
||||
} else {
|
||||
$self->maniaControl->log("Error while updating votes: " . $data->data->message);
|
||||
$this->maniaControl->log("Error while updating votes: " . $data->data->message);
|
||||
if ($data->data->message === "invalid session") {
|
||||
unset($this->mxKarma['session']);
|
||||
return;
|
||||
}
|
||||
// TODO remove temp trigger
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Error while updating votes: " . $data->data->message . " " . KarmaPlugin::MX_KARMA_URL . $self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($self->mxKarma['session']->sessionKey));
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice("Error while updating votes: " . $data->data->message . " " . KarmaPlugin::MX_KARMA_URL . self::MX_KARMA_SAVEVOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey));
|
||||
}
|
||||
} else {
|
||||
$self->maniaControl->log($error);
|
||||
$this->maniaControl->log($error);
|
||||
}
|
||||
}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
}
|
||||
|
@ -100,21 +100,21 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener {
|
||||
|
||||
$this->initTables();
|
||||
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100);
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING, 15);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_RATIO_RANKING, 100);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_HITS_POINTS_RANKING, 15);
|
||||
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3);
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_REQUIRED_RECORDS, 3);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAX_STORED_RECORDS, 50);
|
||||
|
||||
$script = $this->maniaControl->client->getScriptName();
|
||||
|
||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() === 'tm') {
|
||||
//TODO also add obstacle here as default
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RECORDS);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RECORDS);
|
||||
} else if ($script["CurrentValue"] === 'InstaDM.Script.txt') {
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_RATIOS);
|
||||
} else {
|
||||
$maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_POINTS);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MIN_RANKING_TYPE, self::RANKING_TYPE_POINTS);
|
||||
}
|
||||
|
||||
//Check if the type is Correct
|
||||
|
Reference in New Issue
Block a user