Added /list author command

This commit is contained in:
Max Klaversma 2014-04-30 19:18:37 +02:00 committed by Steffen Schröder
parent 1f988ab27e
commit a9db406f9a

View File

@ -329,12 +329,36 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
$this->showMapListDate(true, $player); $this->showMapListDate(true, $player);
} elseif($chatCommands[1] == 'oldest') { } elseif($chatCommands[1] == 'oldest') {
$this->showMapListDate(false, $player); $this->showMapListDate(false, $player);
} elseif($chatCommands[1] == 'author') {
if(isset($chatCommands[2])) {
$this->showMaplistAuthor($chatCommands[2], $player);
} else {
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
}
} }
} else { } else {
$this->maniaControl->mapManager->mapList->showMapList($player); $this->maniaControl->mapManager->mapList->showMapList($player);
} }
} }
private function showMapListAuthor($author, $player) {
$maps = $this->maniaControl->mapManager->getMaps();
$mapList = array();
/** @var Map $map */
foreach($maps as $map) {
if($map->authorLogin == $author) {
$mapList[] = $map;
}
}
if(count($mapList) == 0) {
$this->maniaControl->chat->sendError('There are no maps to show!', $player->login);
return;
}
$this->maniaControl->mapManager->mapList->showMapList($player, $mapList);
}
private function showMapListKarma($best, $player) { private function showMapListKarma($best, $player) {
/** @var \MCTeam\KarmaPlugin $karmaPlugin */ /** @var \MCTeam\KarmaPlugin $karmaPlugin */
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(MapList::DEFAULT_KARMA_PLUGIN); $karmaPlugin = $this->maniaControl->pluginManager->getPlugin(MapList::DEFAULT_KARMA_PLUGIN);