Same bug disabling widgets for donations and general widgets fixed
This commit is contained in:
		| @@ -24,6 +24,8 @@ use ManiaControl\Manialinks\SidebarMenuManager; | |||||||
| use ManiaControl\Players\Player; | use ManiaControl\Players\Player; | ||||||
| use ManiaControl\Players\PlayerManager; | use ManiaControl\Players\PlayerManager; | ||||||
| use ManiaControl\Plugins\Plugin; | use ManiaControl\Plugins\Plugin; | ||||||
|  | use ManiaControl\Settings\Setting; | ||||||
|  | use ManiaControl\Settings\SettingManager; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * ManiaControl Donation Plugin |  * ManiaControl Donation Plugin | ||||||
| @@ -37,7 +39,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const ID                               = 3; | 	const ID                               = 3; | ||||||
| 	const VERSION                          = 0.1; | 	const VERSION                          = 0.11; | ||||||
| 	const AUTHOR                           = 'MCTeam'; | 	const AUTHOR                           = 'MCTeam'; | ||||||
| 	const NAME                             = 'Donation Plugin'; | 	const NAME                             = 'Donation Plugin'; | ||||||
| 	const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements'; | 	const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements'; | ||||||
| @@ -113,6 +115,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb | |||||||
| 		// Register for callbacks | 		// Register for callbacks | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); | ||||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); | ||||||
|  | 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); | ||||||
|  |  | ||||||
| 		// Define player stats | 		// Define player stats | ||||||
| 		$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); | 		$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); | ||||||
| @@ -137,6 +140,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb | |||||||
| 	public function displayWidget() { | 	public function displayWidget() { | ||||||
| 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { | ||||||
| 			$this->displayDonateWidget(); | 			$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); | 		$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 | 	 * Handle ManialinkPageAnswer Callback | ||||||
| 	 * | 	 * | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 * Constants | 	 * Constants | ||||||
| 	 */ | 	 */ | ||||||
| 	const PLUGIN_ID      = 1; | 	const PLUGIN_ID      = 1; | ||||||
| 	const PLUGIN_VERSION = 0.11; | 	const PLUGIN_VERSION = 0.12; | ||||||
| 	const PLUGIN_NAME    = 'WidgetPlugin'; | 	const PLUGIN_NAME    = 'WidgetPlugin'; | ||||||
| 	const PLUGIN_AUTHOR  = 'MCTeam'; | 	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)) { | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { | ||||||
| 			$this->maniaControl->getModeScriptEventManager()->setSiegeProgressionUIPosition("160.", "-67.", "0."); | 			$this->maniaControl->getModeScriptEventManager()->setSiegeProgressionUIPosition("160.", "-67.", "0."); | ||||||
| 			$this->displayMapWidget(); | 			$this->displayMapWidget(); | ||||||
|  | 		} else { | ||||||
|  | 			$this->closeWidget(self::MLID_MAP_WIDGET); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { | ||||||
| 			$this->displayClockWidget(); | 			$this->displayClockWidget(); | ||||||
|  | 		} else { | ||||||
|  | 			$this->closeWidget(self::MLID_CLOCK_WIDGET); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { | 		if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { | ||||||
| 			$this->displayServerInfoWidget(); | 			$this->displayServerInfoWidget(); | ||||||
|  | 		} else { | ||||||
|  | 			$this->closeWidget(self::MLID_SERVERINFO_WIDGET); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -619,7 +627,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { | |||||||
| 	 */ | 	 */ | ||||||
| 	public function updateSettings(Setting $setting) { | 	public function updateSettings(Setting $setting) { | ||||||
| 		if ($setting->belongsToClass($this)) { | 		if ($setting->belongsToClass($this)) { | ||||||
| 			$this->displayWIdgets(); | 			$this->displayWidgets(); | ||||||
|  |  | ||||||
| 			//Update Nadeo Default Widgets | 			//Update Nadeo Default Widgets | ||||||
| 			if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) { | 			if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user