changed direct public access of maniacontrol properties to using getter methods
This commit is contained in:
@ -80,13 +80,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
$thisClass = get_class();
|
||||
$maniaControl->settingManager->initSetting($thisClass, self::SETTING_MX_KARMA_ACTIVATED, true);
|
||||
$maniaControl->settingManager->initSetting($thisClass, self::SETTING_MX_KARMA_IMPORTING, true);
|
||||
$maniaControl->settingManager->initSetting($thisClass, self::SETTING_WIDGET_DISPLAY_MX, true);
|
||||
$servers = $maniaControl->server->getAllServers();
|
||||
$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_MX_KARMA_ACTIVATED, true);
|
||||
$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_MX_KARMA_IMPORTING, true);
|
||||
$maniaControl->getSettingManager()->initSetting($thisClass, self::SETTING_WIDGET_DISPLAY_MX, true);
|
||||
$servers = $maniaControl->getServer()->getAllServers();
|
||||
foreach ($servers as $server) {
|
||||
$settingName = self::buildKarmaSettingName($server->login);
|
||||
$maniaControl->settingManager->initSetting($thisClass, $settingName, '');
|
||||
$maniaControl->getSettingManager()->initSetting($thisClass, $settingName, '');
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,30 +144,30 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
// Init database
|
||||
$this->initTables();
|
||||
|
||||
// Init settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_AVAILABLE_VOTES, '-2,2');
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_ENABLE, true);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma');
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_POSX, 160 - 27.5);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEWKARMA, true);
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AVAILABLE_VOTES, '-2,2');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, 160 - 27.5);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEWKARMA, true);
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'importMxKarmaVotes');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::ENDMAP, $this, 'sendMxKarmaVotes');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
// Callbacks
|
||||
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000);
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'importMxKarmaVotes');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'sendMxKarmaVotes');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
|
||||
// Define player stats
|
||||
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYER_MAPVOTES);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_MAPVOTES);
|
||||
|
||||
// Register Stat in Simple StatsList
|
||||
$this->maniaControl->statisticManager->getSimpleStatsList()->registerStat(self::STAT_PLAYER_MAPVOTES, 100, "VM");
|
||||
$this->maniaControl->getStatisticManager()->getSimpleStatsList()->registerStat(self::STAT_PLAYER_MAPVOTES, 100, "VM");
|
||||
|
||||
$this->updateManialink = true;
|
||||
|
||||
@ -176,13 +176,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->mxKarma['startTime'] = time();
|
||||
|
||||
//Check if Karma Code got specified, and inform admin that it would be good to specify one
|
||||
$serverLogin = $this->maniaControl->server->login;
|
||||
$serverLogin = $this->maniaControl->getServer()->login;
|
||||
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
||||
$mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
|
||||
$mxKarmaCode = $this->maniaControl->getSettingManager()->getSettingValue($this, $karmaSettingName);
|
||||
|
||||
if (!$mxKarmaCode) {
|
||||
$permission = $this->maniaControl->settingManager->getSettingValue($this->maniaControl->authenticationManager, PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||
$this->maniaControl->chat->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission);
|
||||
$permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins("Please specify a Mania-Exchange Karma Key in the Karma-Plugin settings!", $permission);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -192,7 +192,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* Create necessary database tables
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
// Create local table
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_KARMA . "` (
|
||||
@ -228,13 +228,13 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* Open a Mx Karma Session
|
||||
*/
|
||||
private function mxKarmaOpenSession() {
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$serverLogin = $this->maniaControl->server->login;
|
||||
$serverLogin = $this->maniaControl->getServer()->login;
|
||||
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
||||
$mxKarmaCode = $this->maniaControl->settingManager->getSettingValue($this, $karmaSettingName);
|
||||
$mxKarmaCode = $this->maniaControl->getSettingManager()->getSettingValue($this, $karmaSettingName);
|
||||
|
||||
if (!$mxKarmaCode) {
|
||||
return;
|
||||
@ -250,15 +250,15 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$this->mxKarma['connectionInProgress'] = true;
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($json, $error) use ($mxKarmaCode) {
|
||||
$this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($mxKarmaCode) {
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
if ($error) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('mx karma error: ' . $error);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('auth error', $json, $data);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $json, $data);
|
||||
return;
|
||||
}
|
||||
if ($data->success) {
|
||||
@ -267,7 +267,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
} else {
|
||||
$this->maniaControl->log("Error while authenticating on Mania-Exchange Karma");
|
||||
// TODO remove temp trigger
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('auth error', $data->data->message);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message);
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
}
|
||||
}, AsynchronousFileReader::CONTENT_TYPE_JSON, 1000);
|
||||
@ -285,15 +285,15 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$query .= '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey);
|
||||
$query .= '&activationHash=' . urlencode($hash);
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($query, function ($json, $error) use ($query) {
|
||||
$this->maniaControl->getFileReader()->loadFile($query, function ($json, $error) use ($query) {
|
||||
$this->mxKarma['connectionInProgress'] = false;
|
||||
if ($error) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('mx karma error', $error);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('parse error', $json, $data);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data);
|
||||
return;
|
||||
}
|
||||
if ($data->success && $data->data->activated) {
|
||||
@ -303,10 +303,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->getMxKarmaVotes();
|
||||
} else {
|
||||
if ($data->data->message === 'invalid hash') {
|
||||
$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);
|
||||
$permission = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getAuthenticationManager(), PluginMenu::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins("Invalid Mania-Exchange Karma code in Karma Plugin specified!", $permission);
|
||||
} else {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('auth error', $data->data->message, $query);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error', $data->data->message, $query);
|
||||
}
|
||||
$this->maniaControl->log("Error while activating Mania-Exchange Karma Session: " . $data->data->message);
|
||||
unset($this->mxKarma['session']);
|
||||
@ -329,7 +329,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* Fetch the mxKarmaVotes for the current map
|
||||
*/
|
||||
public function getMxKarmaVotes(Player $player = null) {
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -340,25 +340,25 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
|
||||
$properties = array();
|
||||
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
$gameMode = $this->maniaControl->getServer()->getGameMode(true);
|
||||
if ($gameMode === 'Script') {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$scriptName = $this->maniaControl->getClient()->getScriptName();
|
||||
$properties['gamemode'] = $scriptName['CurrentValue'];
|
||||
} else {
|
||||
$properties['gamemode'] = $gameMode;
|
||||
}
|
||||
|
||||
$properties['titleid'] = $this->maniaControl->server->titleId;
|
||||
$properties['titleid'] = $this->maniaControl->getServer()->titleId;
|
||||
$properties['mapuid'] = $map->uid;
|
||||
|
||||
if (!$player) {
|
||||
$properties['getvotesonly'] = false;
|
||||
$properties['playerlogins'] = array();
|
||||
foreach ($this->maniaControl->playerManager->getPlayers() as $loopPlayer) {
|
||||
foreach ($this->maniaControl->getPlayerManager()->getPlayers() as $loopPlayer) {
|
||||
$properties['playerlogins'][] = $loopPlayer->login;
|
||||
}
|
||||
} else {
|
||||
@ -367,18 +367,18 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
$content = json_encode($properties);
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json,
|
||||
$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_GET_MAP_RATING . '?sessionKey=' . urlencode($this->mxKarma['session']->sessionKey), function ($json,
|
||||
$error) use
|
||||
(
|
||||
&$player
|
||||
) {
|
||||
if ($error) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('mx karma error', $error);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('parse error', $json, $data);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
$this->updateManialink = true;
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_MXUPDATED, $this->mxKarma);
|
||||
$this->maniaControl->log('MX-Karma Votes successfully fetched!');
|
||||
} else {
|
||||
// Problem occurred
|
||||
@ -404,7 +404,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
if ($data->data->message === 'invalid session') {
|
||||
unset($this->mxKarma['session']);
|
||||
} else {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('fetch error', $data->data->message, self::MX_KARMA_GET_MAP_RATING, $this->mxKarma['session']);
|
||||
}
|
||||
}
|
||||
}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
@ -414,7 +414,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
$this->maniaControl->manialinkManager->hideManialink(self::MLID_KARMA);
|
||||
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_KARMA);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,7 +425,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
if (isset($this->mxKarma['map'])) {
|
||||
$votes = array();
|
||||
foreach ($this->mxKarma['votes'] as $login => $value) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
array_push($votes, array('login' => $login, 'nickname' => $player->rawNickname, 'vote' => $value));
|
||||
}
|
||||
$this->postKarmaVotes($this->mxKarma['map'], $votes);
|
||||
@ -455,7 +455,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
$gameMode = $this->maniaControl->getServer()->getGameMode(true);
|
||||
|
||||
if (empty($votes)) {
|
||||
return;
|
||||
@ -463,7 +463,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$properties = array();
|
||||
if ($gameMode === 'Script') {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$scriptName = $this->maniaControl->getClient()->getScriptName();
|
||||
$properties['gamemode'] = $scriptName['CurrentValue'];
|
||||
} else {
|
||||
$properties['gamemode'] = $gameMode;
|
||||
@ -476,7 +476,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
}
|
||||
|
||||
$properties['votes'] = $votes;
|
||||
$properties['titleid'] = $this->maniaControl->server->titleId;
|
||||
$properties['titleid'] = $this->maniaControl->getServer()->titleId;
|
||||
$properties['mapname'] = $map->rawName;
|
||||
$properties['mapuid'] = $map->uid;
|
||||
$properties['mapauthor'] = $map->authorLogin;
|
||||
@ -484,15 +484,15 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$content = json_encode($properties);
|
||||
|
||||
$this->maniaControl->fileReader->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json,
|
||||
$this->maniaControl->getFileReader()->postData(self::MX_KARMA_URL . self::MX_KARMA_SAVE_VOTES . "?sessionKey=" . urlencode($this->mxKarma['session']->sessionKey), function ($json,
|
||||
$error) {
|
||||
if ($error) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('mx karma error', $error);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('mx karma error', $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('parse error', $json, $data);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('parse error', $json, $data);
|
||||
return;
|
||||
}
|
||||
if ($data->success) {
|
||||
@ -503,7 +503,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
if ($data->data->message === "invalid session") {
|
||||
unset($this->mxKarma['session']);
|
||||
} else {
|
||||
$this->maniaControl->errorHandler->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']);
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('saving error', $data->data->message, self::MX_KARMA_SAVE_VOTES, $this->mxKarma['session']);
|
||||
}
|
||||
}
|
||||
}, $content, false, AsynchronousFileReader::CONTENT_TYPE_JSON);
|
||||
@ -546,7 +546,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
public function handlePlayerChat(array $chatCallback) {
|
||||
$login = $chatCallback[1][1];
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@ -565,10 +565,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$vote = $countPositive - $countNegative;
|
||||
$success = $this->handleVote($player, $vote);
|
||||
if (!$success) {
|
||||
$this->maniaControl->chat->sendError('Error occurred.', $player->login);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player->login);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->chat->sendSuccess('Vote updated!', $player->login);
|
||||
$this->maniaControl->getChat()->sendSuccess('Vote updated!', $player->login);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -580,7 +580,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
*/
|
||||
private function handleVote(Player $player, $vote) {
|
||||
// Check vote
|
||||
$votesSetting = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_AVAILABLE_VOTES);
|
||||
$votesSetting = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AVAILABLE_VOTES);
|
||||
$votes = explode(',', $votesSetting);
|
||||
$voteLow = intval($votes[0]);
|
||||
$voteHigh = $voteLow + 2;
|
||||
@ -597,10 +597,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$vote /= $voteHigh;
|
||||
|
||||
// Save vote
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
|
||||
// Update vote in MX karma array
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) && isset($this->mxKarma['session'])) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED) && isset($this->mxKarma['session'])) {
|
||||
if (!isset($this->mxKarma['votes'][$player->login])) {
|
||||
if (!isset($this->mxKarma['voteCount'])) {
|
||||
$this->mxKarma['voteCount'] = 0;
|
||||
@ -633,14 +633,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$voted = $this->getPlayerVote($player, $map);
|
||||
if (!$voted) {
|
||||
$this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->server->index);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->getServer()->index);
|
||||
}
|
||||
|
||||
$success = $this->savePlayerVote($player, $map, $vote);
|
||||
if (!$success) {
|
||||
return false;
|
||||
}
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_KARMA_CHANGED);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_KARMA_CHANGED);
|
||||
$this->updateManialink = true;
|
||||
return true;
|
||||
}
|
||||
@ -653,7 +653,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @return int
|
||||
*/
|
||||
public function getPlayerVote(Player $player, Map $map) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT * FROM `" . self::TABLE_KARMA . "`
|
||||
WHERE `playerIndex` = {$player->index}
|
||||
AND `mapIndex` = {$map->index}
|
||||
@ -682,7 +682,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @return bool
|
||||
*/
|
||||
private function savePlayerVote(Player $player, Map $map, $vote) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_KARMA . "` (
|
||||
`mapIndex`,
|
||||
`playerIndex`,
|
||||
@ -709,10 +709,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @return array
|
||||
*/
|
||||
public function getMapPlayerVotes(Map $map) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT * FROM `" . self::TABLE_KARMA . "`
|
||||
WHERE `mapIndex` = {$map->index}
|
||||
AND `vote` >= 0";
|
||||
AND `vote` >= 0;";
|
||||
$result = $mysqli->query($query);
|
||||
if ($mysqli->error) {
|
||||
trigger_error($mysqli->error);
|
||||
@ -721,7 +721,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$votes = array();
|
||||
while ($vote = $result->fetch_object()) {
|
||||
$player = $this->maniaControl->playerManager->getPlayerByIndex($vote->playerIndex);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayerByIndex($vote->playerIndex);
|
||||
$karma = $vote->vote;
|
||||
$voteArray = array('player' => $player, 'karma' => $karma);
|
||||
array_push($votes, $voteArray);
|
||||
@ -745,7 +745,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$serverLogin = $this->maniaControl->server->login;
|
||||
$serverLogin = $this->maniaControl->getServer()->login;
|
||||
$karmaSettingName = self::buildKarmaSettingName($serverLogin);
|
||||
|
||||
switch ($setting->setting) {
|
||||
@ -761,7 +761,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$this->handle1Second(time());
|
||||
} else {
|
||||
$this->updateManialink = false;
|
||||
$this->maniaControl->manialinkManager->hideManialink(self::MLID_KARMA);
|
||||
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_KARMA);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -776,17 +776,17 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$displayMxKarma = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX);
|
||||
$displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX);
|
||||
|
||||
// Get players
|
||||
$players = $this->updateManialink;
|
||||
if ($players === true) {
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
}
|
||||
$this->updateManialink = false;
|
||||
|
||||
// Get map karma
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
|
||||
// Display the mx Karma if the setting is chosen and the MX session is available
|
||||
if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) {
|
||||
@ -798,7 +798,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
$voteCount = $votes['count'];
|
||||
}
|
||||
|
||||
if ($this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) {
|
||||
// Build karma manialink
|
||||
$this->buildManialink();
|
||||
|
||||
@ -832,7 +832,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
// $votesFrame->removeChildren();
|
||||
|
||||
// Send manialink
|
||||
$this->maniaControl->manialinkManager->sendManialink($this->manialink, $login);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink, $login);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -844,7 +844,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @return float | bool
|
||||
*/
|
||||
public function getMapKarma(Map $map) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT AVG(`vote`) AS `karma` FROM `" . self::TABLE_KARMA . "`
|
||||
WHERE `mapIndex` = {$map->index}
|
||||
AND `vote` >= 0;";
|
||||
@ -873,7 +873,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @return array
|
||||
*/
|
||||
public function getMapVotes(Map $map) {
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT `vote`, COUNT(`vote`) AS `count` FROM `" . self::TABLE_KARMA . "`
|
||||
WHERE `mapIndex` = {$map->index}
|
||||
AND `vote` >= 0
|
||||
@ -904,14 +904,14 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_TITLE);
|
||||
$posX = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSX);
|
||||
$posY = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_POSY);
|
||||
$width = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
|
||||
$height = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_WIDGET_HEIGHT);
|
||||
$labelStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultLabelStyle();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$title = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_TITLE);
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_POSY);
|
||||
$width = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_WIDTH);
|
||||
$height = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_HEIGHT);
|
||||
$labelStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
|
||||
$manialink = new ManiaLink(self::MLID_KARMA);
|
||||
|
||||
@ -962,11 +962,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* @param Map $map
|
||||
*/
|
||||
public function importMxKarmaVotes(Map $map) {
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_IMPORTING)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -977,7 +977,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->database->mysqli;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT `mapImported` FROM `" . self::MX_IMPORT_TABLE . "`
|
||||
WHERE `mapIndex` = {$map->index};";
|
||||
$result = $mysqli->query($query);
|
||||
@ -1031,7 +1031,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
* Save Mx Karma Votes at MapEnd
|
||||
*/
|
||||
public function sendMxKarmaVotes(Map $map) {
|
||||
if (!$this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MX_KARMA_ACTIVATED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user