small fixes/cleanups

This commit is contained in:
kremsy 2015-02-01 11:34:51 +01:00
parent fd7770d167
commit ef90574ca0
3 changed files with 9 additions and 5 deletions

View File

@ -130,14 +130,18 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
} }
} }
// search for matching maps //Search the Maps
$this->maniaControl->getMapManager()->getMXManager()->fetchMapsAsync(function (array $maps) use (&$player) { $mxSearch = new ManiaExchangeMapSearch($this->maniaControl);
$mxSearch->setAuthorName($author);
$mxSearch->setEnvironments($environment);
$mxSearch->setMapName($searchString);
$mxSearch->fetchMapsAsync(function (array $maps) use (&$player) {
if (!$maps) { if (!$maps) {
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login); $this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login);
return; return;
} }
$this->showManiaExchangeList($maps, $player); $this->showManiaExchangeList($maps, $player);
}, $searchString, $author, $environment); });
} }
/** /**

View File

@ -270,7 +270,7 @@ class ManiaExchangeManager {
/** /**
* @deprecated * @deprecated
* @see \ManiaControl\ManiaExchange\ManiaExchangeManager::fetchMapsAsync() * @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
*/ */
public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) { public function getMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $searchOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
$this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder); $this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder);

View File

@ -454,7 +454,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$votes = $karmaPlugin->getMapVotes($map); $votes = $karmaPlugin->getMapVotes($map);
} }
if (is_numeric($karma)) { if (is_numeric($karma) && $votes['count'] > 0) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)
) { ) {
$karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')'; $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';