From ef90574ca09f8077aee8210a1951653e48aed21c Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 1 Feb 2015 11:34:51 +0100 Subject: [PATCH] small fixes/cleanups --- core/ManiaExchange/ManiaExchangeList.php | 10 +++++++--- core/ManiaExchange/ManiaExchangeManager.php | 2 +- core/Maps/MapList.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 24c8f71c..9d061dd4 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -130,14 +130,18 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } } - // search for matching maps - $this->maniaControl->getMapManager()->getMXManager()->fetchMapsAsync(function (array $maps) use (&$player) { + //Search the Maps + $mxSearch = new ManiaExchangeMapSearch($this->maniaControl); + $mxSearch->setAuthorName($author); + $mxSearch->setEnvironments($environment); + $mxSearch->setMapName($searchString); + $mxSearch->fetchMapsAsync(function (array $maps) use (&$player) { if (!$maps) { $this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login); return; } $this->showManiaExchangeList($maps, $player); - }, $searchString, $author, $environment); + }); } /** diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index d7fc5509..f220ab3f 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -270,7 +270,7 @@ class ManiaExchangeManager { /** * @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) { $this->fetchMapsAsync($function, $name, $author, $env, $maxMapsReturned, $searchOrder); diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 8246d009..728d74f5 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -454,7 +454,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $votes = $karmaPlugin->getMapVotes($map); } - if (is_numeric($karma)) { + if (is_numeric($karma) && $votes['count'] > 0) { if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) ) { $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';