karma setting recgoniation

This commit is contained in:
kremsy 2014-03-12 13:53:21 +01:00 committed by Steffen Schröder
parent 937f8f3f52
commit 689e572c62

View File

@ -14,6 +14,7 @@ use ManiaControl\Maps\MapManager;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
use ManiaControl\Settings\SettingManager;
/** /**
* ManiaControl Karma Plugin * ManiaControl Karma Plugin
@ -100,6 +101,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'sendMxKarmaVotes'); $this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_ENDMAP, $this, 'sendMxKarmaVotes');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
$this->maniaControl->callbackManager->registerCallbackListener(SettingManager::CB_SETTINGS_CHANGED, $this, 'updateSettings');
// Define player stats // Define player stats
$this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYER_MAPVOTES); $this->maniaControl->statisticManager->defineStatMetaData(self::STAT_PLAYER_MAPVOTES);
@ -555,6 +557,23 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$this->manialink = $manialink; $this->manialink = $manialink;
} }
/**
* Update Settings
* @param $class
* @param $settingName
* @param $value
*/
public function updateSettings($class, $settingName, $value){
if(!$class = get_class())
return;
$serverLogin = $this->maniaControl->server->login;
if($settingName == '$l[http://karma.mania-exchange.com/auth/getapikey?server=' . $serverLogin . ']MX Karma Code for ' . $serverLogin . '$l'){
$this->mxKarmaOpenSession();
}
}
/** /**
* Open a Mx Karma Session * Open a Mx Karma Session
*/ */
@ -564,8 +583,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
} }
$serverLogin = $this->maniaControl->server->login; $serverLogin = $this->maniaControl->server->login;
$mxKarmaCode = $this->maniaControl->settingManager->getSetting($this, '$l[http://karma.mania-exchange.com/auth/getapikey?server=' . $serverLogin . ']MX Karma Code for ' . $serverLogin . '$l'); $mxKarmaCode = $this->maniaControl->settingManager->getSetting($this, '$l[http://karma.mania-exchange.com/auth/getapikey?server=' . $serverLogin . ']MX Karma Code for ' . $serverLogin . '$l');
if ($mxKarmaCode == '') { if ($mxKarmaCode == '') {
return; return;
} }