mapqueue improvement

This commit is contained in:
kremsy 2014-08-13 21:33:26 +02:00
parent 73bdeca4d2
commit 9cc16a2fb5
2 changed files with 37 additions and 17 deletions

View File

@ -340,7 +340,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Checks if the Player who opened the Widget has queued the map // Checks if the Player who opened the Widget has queued the map
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($map->uid); $queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($map->uid);
if ($queuer->login == $player->login) { if ($queuer && $queuer->login == $player->login) {
$description = 'Remove ' . $map->getEscapedName() . ' from the Map Queue'; $description = 'Remove ' . $map->getEscapedName() . ' from the Map Queue';
$label->addTooltipLabelFeature($descriptionLabel, $description); $label->addTooltipLabelFeature($descriptionLabel, $description);
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid); $label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);

View File

@ -105,28 +105,29 @@ class MapQueue implements CallbackListener, CommandListener {
/** /**
* Clear the Map Queue * Clear the Map Queue
* *
* @param Player $admin * @param Player $admin |null
*/ */
public function clearMapQueue(Player $admin) { public function clearMapQueue(Player $admin = null) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE) if ($admin && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)
) { ) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin); $this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
return; return;
} }
if (empty($this->queuedMaps)) { if ($admin && empty($this->queuedMaps)) {
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login); $this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login);
return; return;
} }
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
//Destroy map - queue list //Destroy map - queue list
$this->queuedMaps = array(); $this->queuedMaps = array();
if ($admin) {
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
$message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!'; $message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!';
$this->maniaControl->getChat()->sendInformation($message); $this->maniaControl->getChat()->sendInformation($message);
Logger::logInfo($message, true); Logger::logInfo($message, true);
}
// Trigger callback // Trigger callback
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear')); $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('clear'));
@ -227,6 +228,23 @@ class MapQueue implements CallbackListener, CommandListener {
} }
} }
public function serverAddMapToMapQueue($uid) {
$map = $this->maniaControl->getMapManager()->getMapByUid($uid);
if (!$map) {
return false;
}
$this->queuedMaps[$uid] = array(null, $map);
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by the Server.');
// Trigger callback
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
return true;
}
/** /**
* Add a Map to the map-queue * Add a Map to the map-queue
* *
@ -340,14 +358,12 @@ class MapQueue implements CallbackListener, CommandListener {
break; break;
} }
// Player found, so play this map // Player found, so play this map (or if it got juked by the server)
if ($this->maniaControl->getPlayerManager()->getPlayer($player->login) if ($player == null || $this->maniaControl->getPlayerManager()->getPlayer($player->login)) {
) {
break; break;
} }
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN) if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAPQUEUE_ADMIN)) {
) {
//Check if the queuer is a admin //Check if the queuer is a admin
if ($player->authLevel > 0) { if ($player->authLevel > 0) {
break; break;
@ -371,8 +387,12 @@ class MapQueue implements CallbackListener, CommandListener {
return; return;
} }
$map = $this->nextMap[1]; $map = $this->nextMap[1];
//Message only if it's juked by a player (not by the server)
if ($this->nextMap[0]) {
/** @var Map $map */ /** @var Map $map */
$this->maniaControl->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.'); $this->maniaControl->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
}
try { try {
$this->maniaControl->getClient()->setNextMapIdent($map->uid); $this->maniaControl->getClient()->setNextMapIdent($map->uid);