mapqueue improvement
This commit is contained in:
parent
73bdeca4d2
commit
9cc16a2fb5
@ -340,7 +340,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
// Checks if the Player who opened the Widget has queued the map
|
||||
$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';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);
|
||||
|
@ -105,28 +105,29 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
/**
|
||||
* Clear the Map Queue
|
||||
*
|
||||
* @param Player $admin
|
||||
* @param Player $admin |null
|
||||
*/
|
||||
public function clearMapQueue(Player $admin) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)
|
||||
public function clearMapQueue(Player $admin = null) {
|
||||
if ($admin && !$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->queuedMaps)) {
|
||||
if ($admin && empty($this->queuedMaps)) {
|
||||
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
|
||||
//Destroy map - queue list
|
||||
$this->queuedMaps = array();
|
||||
|
||||
if ($admin) {
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!';
|
||||
$this->maniaControl->getChat()->sendInformation($message);
|
||||
Logger::logInfo($message, true);
|
||||
}
|
||||
|
||||
// Trigger callback
|
||||
$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
|
||||
*
|
||||
@ -340,14 +358,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
break;
|
||||
}
|
||||
|
||||
// Player found, so play this map
|
||||
if ($this->maniaControl->getPlayerManager()->getPlayer($player->login)
|
||||
) {
|
||||
// Player found, so play this map (or if it got juked by the server)
|
||||
if ($player == null || $this->maniaControl->getPlayerManager()->getPlayer($player->login)) {
|
||||
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
|
||||
if ($player->authLevel > 0) {
|
||||
break;
|
||||
@ -371,8 +387,12 @@ class MapQueue implements CallbackListener, CommandListener {
|
||||
return;
|
||||
}
|
||||
$map = $this->nextMap[1];
|
||||
|
||||
//Message only if it's juked by a player (not by the server)
|
||||
if ($this->nextMap[0]) {
|
||||
/** @var Map $map */
|
||||
$this->maniaControl->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()->setNextMapIdent($map->uid);
|
||||
|
Loading…
Reference in New Issue
Block a user