improve the check of MatchManagerCore
This commit is contained in:
		| @@ -4,11 +4,9 @@ namespace MatchManagerSuite; | ||||
|  | ||||
| use FML\Controls\Frame; | ||||
| use FML\Controls\Labels\Label_Text; | ||||
| use FML\Controls\Label; | ||||
| use FML\Controls\Quad; | ||||
| use FML\ManiaLink; | ||||
| use ManiaControl\Callbacks\CallbackListener; | ||||
| use ManiaControl\Callbacks\CallbackManager; | ||||
| use ManiaControl\Callbacks\Callbacks; | ||||
| use ManiaControl\Logger; | ||||
| use ManiaControl\ManiaControl; | ||||
| @@ -16,17 +14,17 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener; | ||||
| use ManiaControl\Players\Player; | ||||
| use ManiaControl\Players\PlayerManager; | ||||
| use ManiaControl\Plugins\Plugin; | ||||
| use ManiaControl\Plugins\PluginManager; | ||||
| use ManiaControl\Settings\Setting; | ||||
| use ManiaControl\Settings\SettingManager; | ||||
| use ManiaControl\Commands\CommandListener; | ||||
|  | ||||
|  | ||||
| if (! class_exists('MatchManagerSuite\MatchManagerCore')) { | ||||
| 	$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Players Pause plugin. Install it and restart Maniacontrol'); | ||||
| 	Logger::logError('MatchManager Core is needed to use MatchManager Players Pause plugin. Install it and restart Maniacontrol'); | ||||
| if (!class_exists('MatchManagerSuite\MatchManagerCore')) { | ||||
| 	$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol'); | ||||
| 	Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol'); | ||||
| 	return false; | ||||
| } | ||||
| use MatchManagerSuite\MatchManagerCore; | ||||
|  | ||||
|  | ||||
| /** | ||||
| @@ -40,7 +38,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 	 * Constants | ||||
| 	 */ | ||||
| 	const PLUGIN_ID											= 159; | ||||
| 	const PLUGIN_VERSION									= 1.0; | ||||
| 	const PLUGIN_VERSION									= 1.1; | ||||
| 	const PLUGIN_NAME										= 'MatchManager Players Pause'; | ||||
| 	const PLUGIN_AUTHOR										= 'Beu'; | ||||
|  | ||||
| @@ -60,6 +58,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 	 */ | ||||
| 	/** @var ManiaControl $maniaControl */ | ||||
| 	private $maniaControl 			= null; | ||||
| 	private $MatchManagerCore		= null; | ||||
| 	private $chatprefix				= '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4 | ||||
|  | ||||
| 	private $playerspausestate		= array(); | ||||
| @@ -122,7 +121,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 		$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN); | ||||
|  | ||||
| 		if ($this->MatchManagerCore == Null) { | ||||
| 			throw new \Exception('MatchManager Core is needed to use MatchManager Players Pause plugin'); | ||||
| 			throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME); | ||||
| 		} | ||||
|  | ||||
| 		$this->maniaControl->getCommandManager()->registerCommandListener('pause', $this, 'onCommandSetPausePlayer', false, 'Change status to Pause.'); | ||||
| @@ -133,6 +132,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSX, 152.5, "Position of the Pause widget (on X axis)"); | ||||
| 		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSY, 40, "Position of the Pause widget (on Y axis)"); | ||||
|  | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); | ||||
|  | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); | ||||
| @@ -157,6 +157,20 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 		$this->closePauseWidget(); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * handlePluginUnloaded | ||||
| 	 * | ||||
| 	 * @param  string $pluginClass | ||||
| 	 * @param  Plugin $plugin | ||||
| 	 * @return void | ||||
| 	 */ | ||||
| 	public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) { | ||||
| 		$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled"); | ||||
| 		if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) { | ||||
| 			$this->maniaControl->getPluginManager()->deactivatePlugin((get_class())); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Generate Manialinks variables | ||||
| 	*/ | ||||
| @@ -284,7 +298,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
|  | ||||
|  | ||||
| 	/** | ||||
| 	 * Command /pause for players | ||||
|   | ||||
		Reference in New Issue
	
	Block a user