Add a setting to disable ManiaExchange
This commit is contained in:
@ -71,6 +71,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$actionId = $callback[1][2];
|
||||
$actionArray = explode('.', $actionId);
|
||||
if (count($actionArray) <= 2) {
|
||||
@ -101,6 +102,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showListCommand(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
$this->mapListShown[$player->login] = true;
|
||||
$params = explode(' ', $chatCallback[1][2]);
|
||||
$searchString = '';
|
||||
@ -141,6 +143,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param string $searchString
|
||||
*/
|
||||
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//TODO do more clean solution
|
||||
if($environment == ""){
|
||||
$titleId = $this->maniaControl->getServer()->titleId;
|
||||
@ -191,6 +194,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @internal param array $chatCallback
|
||||
*/
|
||||
private function showManiaExchangeList(array $maps, Player $player) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
// Start offsets
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
@ -340,6 +344,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
* @param $openedWidget
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
//unset when another main widget got opened
|
||||
if ($openedWidget !== 'ManiaExchangeList') {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
@ -355,5 +360,4 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
public function closeWidget(Player $player) {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $enabled = true;
|
||||
private $mxIdUidVector = array();
|
||||
|
||||
/**
|
||||
@ -67,6 +68,22 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
//$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MX_KEY, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status of the plugin
|
||||
*
|
||||
* @param bool $status
|
||||
*/
|
||||
public function setStatus(bool $status) {
|
||||
$this->enabled = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of the plugin
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset Map by Mx Id
|
||||
*
|
||||
@ -84,6 +101,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param mixed $maps
|
||||
*/
|
||||
public function fetchManiaExchangeMapInformation($maps = null) {
|
||||
if (!$this->enabled) return;
|
||||
if ($maps) {
|
||||
// Fetch Information for a single map
|
||||
$maps = array($maps);
|
||||
@ -160,7 +178,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param string $string
|
||||
*/
|
||||
public function fetchMaplistByMixedUidIdString($string) {
|
||||
|
||||
if (!$this->enabled) return;
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -217,6 +235,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param array $mxMapInfos
|
||||
*/
|
||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||
if (!$this->enabled) return;
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
// Save map data
|
||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||
@ -269,6 +288,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapInfo($mapId, callable $function) {
|
||||
if (!$this->enabled) return;
|
||||
// For TM2020
|
||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||
// Get Title Prefix
|
||||
@ -335,6 +355,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
||||
* @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||
if (!$this->enabled) return;
|
||||
$mapSearch = new ManiaExchangeMapSearch($this->maniaControl);
|
||||
$mapSearch->setMapName($name);
|
||||
$mapSearch->setAuthorName($author);
|
||||
|
@ -140,6 +140,8 @@ class ManiaExchangeMapSearch implements UsageInformationAble {
|
||||
* @param callable $function
|
||||
*/
|
||||
public function fetchMapsAsync(callable $function) {
|
||||
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||
|
||||
// compile search URL
|
||||
$parameters = "";
|
||||
|
||||
|
Reference in New Issue
Block a user