From eba2b566538c2c34aa81a226b2e4aed7f8e9ed17 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 16 Mar 2020 11:11:17 +0100 Subject: [PATCH] Same bug disabling widgets for donations and general widgets fixed --- plugins/MCTeam/DonationPlugin.php | 21 ++++++++++++++++++++- plugins/MCTeam/WidgetPlugin.php | 12 ++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 1587e7af..f35858b9 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -24,6 +24,8 @@ use ManiaControl\Manialinks\SidebarMenuManager; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; +use ManiaControl\Settings\Setting; +use ManiaControl\Settings\SettingManager; /** * ManiaControl Donation Plugin @@ -37,7 +39,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb * Constants */ const ID = 3; - const VERSION = 0.1; + const VERSION = 0.11; const AUTHOR = 'MCTeam'; const NAME = 'Donation Plugin'; const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements'; @@ -113,6 +115,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb // Register for callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); // Define player stats $this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); @@ -137,6 +140,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb public function displayWidget() { if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { $this->displayDonateWidget(); + } else { + $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET); } } @@ -237,6 +242,20 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET); } + /** + * Handle Setting Changed Callback + * + * @internal + * @param Setting $setting + */ + public function handleSettingChanged(Setting $setting) { + if (!$setting->belongsToClass($this)) { + return; + } + + $this->displayWidget(); + } + /** * Handle ManialinkPageAnswer Callback * diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 3647ca65..f8d0632c 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -36,7 +36,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Constants */ const PLUGIN_ID = 1; - const PLUGIN_VERSION = 0.11; + const PLUGIN_VERSION = 0.12; const PLUGIN_NAME = 'WidgetPlugin'; const PLUGIN_AUTHOR = 'MCTeam'; @@ -213,12 +213,20 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->maniaControl->getModeScriptEventManager()->setSiegeProgressionUIPosition("160.", "-67.", "0."); $this->displayMapWidget(); + } else { + $this->closeWidget(self::MLID_MAP_WIDGET); } + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { $this->displayClockWidget(); + } else { + $this->closeWidget(self::MLID_CLOCK_WIDGET); } + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); + } else { + $this->closeWidget(self::MLID_SERVERINFO_WIDGET); } } @@ -619,7 +627,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ public function updateSettings(Setting $setting) { if ($setting->belongsToClass($this)) { - $this->displayWIdgets(); + $this->displayWidgets(); //Update Nadeo Default Widgets if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) {