PlayerQueue has been fixed

This commit is contained in:
Max Klaversma 2014-05-01 13:10:06 +02:00 committed by Steffen Schröder
parent 6cf521aef2
commit 2a4ae861a2

View File

@ -85,6 +85,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_ACTIVE_ON_PASS, false); $this->maniaControl->settingManager->initSetting($this, self::QUEUE_ACTIVE_ON_PASS, false);
$this->maniaControl->settingManager->initSetting($this, self::QUEUE_CHATMESSAGES, true); $this->maniaControl->settingManager->initSetting($this, self::QUEUE_CHATMESSAGES, true);
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue'];
foreach($this->maniaControl->playerManager->getPlayers() as $player) { foreach($this->maniaControl->playerManager->getPlayers() as $player) {
if ($player->isSpectator) { if ($player->isSpectator) {
$this->spectators[$player->login] = $player->login; $this->spectators[$player->login] = $player->login;
@ -215,6 +218,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
$this->maniaControl->client->forceSpectator($player->login, 1); $this->maniaControl->client->forceSpectator($player->login, 1);
$this->spectators[$player->login] = $player->login; $this->spectators[$player->login] = $player->login;
$this->showJoinQueueWidget($player); $this->showJoinQueueWidget($player);
$this->showQueueWidgetSpectators();
} }
} else { } else {
$this->removePlayerFromQueue($player->login); $this->removePlayerFromQueue($player->login);
@ -236,17 +240,20 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
} }
} }
public function showQueueWidgetSpectators() {
foreach($this->spectators as $login) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$this->showJoinQueueWidget($player);
}
}
/** /**
* Function called on every second. * Function called on every second.
*/ */
public function handleEverySecond() { public function handleEverySecond() {
if ($this->maxPlayers > (count($this->maniaControl->playerManager->players) - count($this->spectators))) { if ($this->maxPlayers > (count($this->maniaControl->playerManager->players) - count($this->spectators))) {
$this->moveFirstPlayerToPlay(); $this->moveFirstPlayerToPlay();
} $this->showQueueWidgetSpectators();
foreach($this->spectators as $login) {
$player = $this->maniaControl->playerManager->getPlayer($login);
$this->showJoinQueueWidget($player);
} }
foreach($this->showPlay as $showPlay) { foreach($this->showPlay as $showPlay) {
@ -296,6 +303,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
if (count($this->queue) > 0) { if (count($this->queue) > 0) {
$firstPlayer = $this->maniaControl->playerManager->getPlayer($this->queue[0]->login); $firstPlayer = $this->maniaControl->playerManager->getPlayer($this->queue[0]->login);
$this->forcePlayerToPlay($firstPlayer); $this->forcePlayerToPlay($firstPlayer);
$this->showQueueWidgetSpectators();
} }
} }
@ -384,6 +392,8 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
$this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!'); $this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!');
} }
$this->showQueueWidgetSpectators();
return true; return true;
} }
@ -403,6 +413,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
} }
$this->queue = $newQueue; $this->queue = $newQueue;
$this->showQueueWidgetSpectators();
} }
/** /**
@ -412,7 +423,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
*/ */
private function sendChatMessage($message) { private function sendChatMessage($message) {
if ($this->maniaControl->settingManager->getSetting($this, self::QUEUE_CHATMESSAGES)) { if ($this->maniaControl->settingManager->getSetting($this, self::QUEUE_CHATMESSAGES)) {
$this->maniaControl->chat->sendChat('$z$s$090[Queue] ' . $message); $this->maniaControl->chat->sendChat('$090[Queue] ' . $message);
} }
} }
@ -422,11 +433,6 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
* @param Player $player * @param Player $player
*/ */
private function showJoinQueueWidget(Player $player) { private function showJoinQueueWidget(Player $player) {
/*if($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
$this->hideQueueWidget($player);
return;
}*/
$maniaLink = new ManiaLink(self::ML_ID); $maniaLink = new ManiaLink(self::ML_ID);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();