fix error when having one map and no re-order setting value
This commit is contained in:
		| @@ -37,7 +37,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const PLUGIN_ID											= 211; | 	const PLUGIN_ID											= 211; | ||||||
| 	const PLUGIN_VERSION									= 1.2; | 	const PLUGIN_VERSION									= 1.3; | ||||||
| 	const PLUGIN_NAME										= 'MatchManager TMWT Duo Integration'; | 	const PLUGIN_NAME										= 'MatchManager TMWT Duo Integration'; | ||||||
| 	const PLUGIN_AUTHOR										= 'Beu'; | 	const PLUGIN_AUTHOR										= 'Beu'; | ||||||
|  |  | ||||||
| @@ -326,9 +326,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA | |||||||
| 			$this->maniaControl->getClient()->setModeScriptSettings(['S_IsMatchmaking' => true], false); | 			$this->maniaControl->getClient()->setModeScriptSettings(['S_IsMatchmaking' => true], false); | ||||||
| 			$this->maniaControl->getClient()->restartMap(); | 			$this->maniaControl->getClient()->restartMap(); | ||||||
| 		} else if ($this->state === self::STATE_PREMATCH) { | 		} else if ($this->state === self::STATE_PREMATCH) { | ||||||
|  |  | ||||||
| 			$teamsUrl = $this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl'); | 			$teamsUrl = $this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl'); | ||||||
| 			if ($teamsUrl !== '') { | 			if ($teamsUrl !== null && $teamsUrl !== '') { | ||||||
| 				$response = WebReader::getUrl($teamsUrl); | 				$response = WebReader::getUrl($teamsUrl); | ||||||
| 				$content  = $response->getContent(); | 				$content  = $response->getContent(); | ||||||
| 				$json = json_decode($content); | 				$json = json_decode($content); | ||||||
| @@ -416,19 +415,23 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA | |||||||
| 	 | 	 | ||||||
| 				$mapUids = array_column($json->playlist, 'uid'); | 				$mapUids = array_column($json->playlist, 'uid'); | ||||||
|  |  | ||||||
| 				$order = explode(',', $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_OVERRIDEMAPORDER)); | 				$mapOrderSetting = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_OVERRIDEMAPORDER); | ||||||
|  |  | ||||||
| 				if (count($order) === count($mapUids)) { | 				if ($mapOrderSetting !== '') { | ||||||
| 					$this->log("Re-ordering maps"); | 					$order = array_map('trim', explode(',', $mapOrderSetting)); | ||||||
| 					try { |  | ||||||
| 						$orderedMapUid = []; | 					if (count($order) === count($mapUids)) { | ||||||
| 						foreach ($order as $number) { | 						$this->log("Re-ordering maps"); | ||||||
| 							$orderedMapUid[] = $mapUids[$number - 1]; | 						try { | ||||||
|  | 							$orderedMapUid = []; | ||||||
|  | 							foreach ($order as $number) { | ||||||
|  | 								$orderedMapUid[] = $mapUids[$number - 1]; | ||||||
|  | 							} | ||||||
|  | 							$mapUids = $orderedMapUid; | ||||||
|  | 						} catch (\Throwable $th) { | ||||||
|  | 							$this->logError("Invalid Map order setting"); | ||||||
|  | 							$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() ."Invalid Map order setting"); | ||||||
| 						} | 						} | ||||||
| 						$mapUids = $orderedMapUid; |  | ||||||
| 					} catch (\Throwable $th) { |  | ||||||
| 						$this->logError("Invalid Map order setting"); |  | ||||||
| 						$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() ."Invalid Map order setting"); |  | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user