From 5e0e801a957f5f4e0428c7cdf1e078877861dc29 Mon Sep 17 00:00:00 2001 From: Beu Date: Sun, 13 Jun 2021 16:15:52 +0200 Subject: [PATCH] prevent to use the plugin without Core --- MatchManagerSuite/MatchManagerWidget.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MatchManagerSuite/MatchManagerWidget.php b/MatchManagerSuite/MatchManagerWidget.php index 392a118..306343f 100644 --- a/MatchManagerSuite/MatchManagerWidget.php +++ b/MatchManagerSuite/MatchManagerWidget.php @@ -23,6 +23,12 @@ use ManiaControl\Plugins\Plugin; use ManiaControl\Settings\Setting; use ManiaControl\Settings\SettingManager; use ManiaControl\Utils\Formatter; + +if (! class_exists('MatchManagerSuite\MatchManagerCore')) { + $this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Widget plugin. Install it and restart Maniacontrol'); + Logger::logError('MatchManager Core is needed to use MatchManager Widget plugin. Install it and restart Maniacontrol'); + return false; +} use MatchManagerSuite\MatchManagerCore; @@ -37,7 +43,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene * Constants */ const PLUGIN_ID = 153; - const PLUGIN_VERSION = 1.0; + const PLUGIN_VERSION = 1.1; const PLUGIN_NAME = 'MatchManager Widget'; const PLUGIN_AUTHOR = 'Beu'; @@ -120,6 +126,10 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene $this->maniaControl = $maniaControl; $this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN); + if ($this->MatchManagerCore == Null) { + throw new \Exception('MatchManager Core is needed to use MatchManager Widget plugin'); + } + // Callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings'); @@ -502,3 +512,4 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene } } +