fix php 8.4 compatibility + improve logging / chat messages
This commit is contained in:
		| @@ -37,6 +37,8 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 	const PLUGIN_NAME		= 'MatchManager eCircuitMania'; | ||||
| 	const PLUGIN_AUTHOR		= 'Beu'; | ||||
|  | ||||
| 	const LOG_PREFIX					= '[MatchManagerECircuitMania] '; | ||||
|  | ||||
| 	const MATCHMANAGERCORE_PLUGIN		= 'MatchManagerSuite\MatchManagerCore'; | ||||
| 	const MATCHMANAGERADMINUI_PLUGIN	= 'MatchManagerSuite\MatchManagerAdminUI'; | ||||
|  | ||||
| @@ -108,7 +110,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 				$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN); | ||||
| 				if ($this->MatchManagerCore === null) { | ||||
| 					$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use ' . self::PLUGIN_NAME . ' plugin.'); | ||||
| 					$this->maniaControl->getPluginManager()->deactivatePlugin((get_class())); | ||||
| 					$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this))); | ||||
| 					return; | ||||
| 				} | ||||
|  | ||||
| @@ -130,6 +132,24 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 		$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ML_ACTION_OPENSETTINGS, $this, 'handleActionOpenSettings'); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Custom log function to add prefix | ||||
| 	 *  | ||||
| 	 * @param mixed $message | ||||
| 	 */ | ||||
| 	private function log(mixed $message) { | ||||
| 		Logger::log(self::LOG_PREFIX . $message); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Custom logError function to add prefix | ||||
| 	 *  | ||||
| 	 * @param mixed $message | ||||
| 	 */ | ||||
| 	private function logError(mixed $message) { | ||||
| 		Logger::logError(self::LOG_PREFIX . $message); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * handle Plugin Loaded | ||||
| 	 *  | ||||
| @@ -214,7 +234,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 		if ($request !== null) { | ||||
| 			$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) { | ||||
| 				if ($content !== "Created" || $error !== null) { | ||||
| 					Logger::logWarning("Error on the 'addRoundTime' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 					$this->logError("Error on the 'addRoundTime' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 				} | ||||
| 			})->postData(); | ||||
| 		} | ||||
| @@ -226,7 +246,6 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
|  | ||||
| 		$scores = []; | ||||
| 		foreach ($structure->getPlayerScores() as $playerscore) { | ||||
| 			if ($playerscore->getMatchPoints() <= -2000) continue; | ||||
| 			$scores[] = $playerscore; | ||||
| 		} | ||||
|  | ||||
| @@ -284,7 +303,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 		if ($request !== null) { | ||||
| 			$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) { | ||||
| 				if ($content !== "Created" || $error !== null) { | ||||
| 					Logger::logWarning("Error on the 'addRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 					$this->logError("Error on the 'addRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 				} | ||||
| 			})->postData(); | ||||
| 		} | ||||
| @@ -304,7 +323,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer | ||||
| 		if ($request !== null) { | ||||
| 			$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) { | ||||
| 				if ($content !== "Created" || $error !== null) { | ||||
| 					Logger::logWarning("Error on the 'removeRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 					$this->logError("Error on the 'removeRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload); | ||||
| 				} | ||||
| 			})->postData(); | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user