Fixed stuck in spectator problems

This commit is contained in:
Max Klaversma 2014-05-08 19:40:49 +02:00
parent df7c025aaa
commit 17a67326aa

View File

@ -33,7 +33,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* Constants * Constants
*/ */
const ID = 22; const ID = 22;
const VERSION = 0.11; const VERSION = 0.12;
const ML_ID = 'Queue.Widget'; const ML_ID = 'Queue.Widget';
const ML_ADDTOQUEUE = 'Queue.Add'; const ML_ADDTOQUEUE = 'Queue.Add';
const ML_REMOVEFROMQUEUE = 'Queue.Remove'; const ML_REMOVEFROMQUEUE = 'Queue.Remove';
@ -90,6 +90,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
$maxPlayers = $this->maniaControl->client->getMaxPlayers(); $maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue']; $this->maxPlayers = $maxPlayers['CurrentValue'];
if (!($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false)) {
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;
@ -98,6 +99,7 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
} }
} }
} }
}
/** /**
* Unload the plugin and its resources * Unload the plugin and its resources
@ -166,6 +168,10 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param Player $player * @param Player $player
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers(); $maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue']; $this->maxPlayers = $maxPlayers['CurrentValue'];
@ -188,6 +194,10 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param Player $player * @param Player $player
*/ */
public function handlePlayerDisconnect(Player $player) { public function handlePlayerDisconnect(Player $player) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers(); $maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue']; $this->maxPlayers = $maxPlayers['CurrentValue'];
@ -204,6 +214,10 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param array $callback * @param array $callback
*/ */
public function handlePlayerInfoChanged(array $callback) { public function handlePlayerInfoChanged(array $callback) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$login = $callback[1][0]['Login']; $login = $callback[1][0]['Login'];
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
@ -246,6 +260,10 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* Function called on every second. * Function called on every second.
*/ */
public function handleEverySecond() { public function handleEverySecond() {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
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(); $this->showQueueWidgetSpectators();
@ -265,6 +283,10 @@ class QueuePlugin implements CallbackListener, ManialinkPageAnswerListener, Time
* @param $currentMap * @param $currentMap
*/ */
public function handleBeginMap($currentMap) { public function handleBeginMap($currentMap) {
if ($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) {
return;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers(); $maxPlayers = $this->maniaControl->client->getMaxPlayers();
$this->maxPlayers = $maxPlayers['CurrentValue']; $this->maxPlayers = $maxPlayers['CurrentValue'];
} }