update serverwidget on player connect / disconnect

This commit is contained in:
kremsy 2014-01-01 20:39:10 +01:00
parent f555af5f4a
commit 98dfae02bd

View File

@ -73,7 +73,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
private $maniaControl = null; private $maniaControl = null;
/** /**
* Load the plugin * Load the plugin
* *
@ -91,6 +90,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect'); $this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute'); $this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
@ -305,8 +305,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
foreach($players as $player) { foreach($players as $player) {
if($player->isSpectator) { if($player->isSpectator) {
$spectatorCount++; $spectatorCount++;
} } else {
else {
$playerCount++; $playerCount++;
} }
} }
@ -446,8 +445,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$map = $this->maniaControl->client->getResponse(); $map = $this->maniaControl->client->getResponse();
$name = $map['Name']; $name = $map['Name'];
$author = $map['Author']; $author = $map['Author'];
} } else {
else {
$requester = $queuedMap[0]; $requester = $queuedMap[0];
$map = $queuedMap[1]; $map = $queuedMap[1];
$name = $map->name; $name = $map->name;
@ -521,7 +519,18 @@ class WidgetPlugin implements CallbackListener, Plugin {
$this->displayClockWidget($player->login); $this->displayClockWidget($player->login);
} }
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget($player->login); $this->displayServerInfoWidget();
}
}
/**
* Handle PlayerConnect callback
*
* @param array $callback
*/
public function handlePlayerDisconnect(array $callback) {
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget();
} }
} }