queue fixes

This commit is contained in:
kremsy 2014-01-24 21:40:12 +01:00 committed by Steffen Schröder
parent d9ba67947a
commit 1d8c9e60e3

View File

@ -3,9 +3,9 @@ use FML\Controls\Frame;
use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad; use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
@ -157,9 +157,12 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
} }
public function handlePlayerDisconnect(array $callback) { public function handlePlayerDisconnect(array $callback) {
$login = $callback[1]->login; /** @var Player $player */
if(isset($this->spectators[$login])) unset($this->spectators[$login]); $player = $callback[1];
$this->removePlayerFromQueue($login); if(isset($this->spectators[$player->login])) {
unset($this->spectators[$player->login]);
}
$this->removePlayerFromQueue($player->login);
$this->moveFirstPlayerToPlay(); $this->moveFirstPlayerToPlay();
} }
@ -201,7 +204,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
} }
public function handleManiaLinkAnswerRemove(array $chatCallback, Player $player) { public function handleManiaLinkAnswerRemove(array $chatCallback, Player $player) {
$this->removePlayerFromQueue($player); $this->removePlayerFromQueue($player->login);
$this->showJoinQueueWidget($player); $this->showJoinQueueWidget($player);
$this->maniaControl->chat->sendChat('$z$s$090[Queue] $<$fff' . $player->nickname . '$> has left the queue!'); $this->maniaControl->chat->sendChat('$z$s$090[Queue] $<$fff' . $player->nickname . '$> has left the queue!');
} }
@ -217,7 +220,9 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
if($this->maniaControl->client->getMaxPlayers()['CurrentValue'] > count($this->maniaControl->playerManager->players)) { if($this->maniaControl->client->getMaxPlayers()['CurrentValue'] > count($this->maniaControl->playerManager->players)) {
$this->maniaControl->client->forceSpectator($player->login, 2); $this->maniaControl->client->forceSpectator($player->login, 2);
$this->maniaControl->client->forceSpectator($player->login, 0); $this->maniaControl->client->forceSpectator($player->login, 0);
if(isset($this->spectators[$player->login])) unset($this->spectators[$player->login]); if(isset($this->spectators[$player->login])) {
unset($this->spectators[$player->login]);
}
$this->removePlayerFromQueue($player->login); $this->removePlayerFromQueue($player->login);
$this->showPlayWidget($player); $this->showPlayWidget($player);
$this->maniaControl->chat->sendChat('$z$s$090[Queue] $<$fff' . $player->nickname . '$> has a free spot and is now playing!'); $this->maniaControl->chat->sendChat('$z$s$090[Queue] $<$fff' . $player->nickname . '$> has a free spot and is now playing!');