changed direct public access of maniacontrol properties to using getter methods
This commit is contained in:
		| @@ -52,11 +52,11 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
| 	 * @see \ManiaControl\Plugins\Plugin::prepare() | ||||
| 	 */ | ||||
| 	public static function prepare(ManiaControl $maniaControl) { | ||||
| 		$maniaControl->settingManager->initSetting(get_class(), self::SETTING_POINT_LIMIT_MULTIPLIER, 10); | ||||
| 		$maniaControl->settingManager->initSetting(get_class(), self::SETTING_POINT_LIMIT_OFFSET, 0); | ||||
| 		$maniaControl->settingManager->initSetting(get_class(), self::SETTING_MIN_POINT_LIMIT, 30); | ||||
| 		$maniaControl->settingManager->initSetting(get_class(), self::SETTING_MAX_POINT_LIMIT, 200); | ||||
| 		$maniaControl->settingManager->initSetting(get_class(), self::SETTING_ACCEPT_OTHER_MODES, false); | ||||
| 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_POINT_LIMIT_MULTIPLIER, 10); | ||||
| 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_POINT_LIMIT_OFFSET, 0); | ||||
| 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_MIN_POINT_LIMIT, 30); | ||||
| 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_MAX_POINT_LIMIT, 200); | ||||
| 		$maniaControl->getSettingManager()->initSetting(get_class(), self::SETTING_ACCEPT_OTHER_MODES, false); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| @@ -100,21 +100,21 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
| 	public function load(ManiaControl $maniaControl) { | ||||
| 		$this->maniaControl = $maniaControl; | ||||
|  | ||||
| 		$allowOthers = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES); | ||||
| 		if (!$allowOthers && $this->maniaControl->server->titleId !== 'SMStormRoyal@nadeolabs') { | ||||
| 		$allowOthers = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ACCEPT_OTHER_MODES); | ||||
| 		if (!$allowOthers && $this->maniaControl->getServer()->titleId !== 'SMStormRoyal@nadeolabs') { | ||||
| 			$error = 'This plugin only supports Royal (check Settings)!'; | ||||
| 			throw new \Exception($error); | ||||
| 		} | ||||
|  | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChangedCallback'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChangedCallback'); | ||||
|  | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINROUND, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | ||||
| 		$this->maniaControl->callbackManager->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChangedCallback'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINROUND, $this, 'updatePointLimit'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleBeginMap'); | ||||
| 		$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChangedCallback'); | ||||
|  | ||||
| 		$this->maniaControl->commandManager->registerCommandListener('setpointlimit', $this, 'commandSetPointlimit', true, 'Setpointlimit XXX or auto'); | ||||
| 		$this->maniaControl->getCommandManager()->registerCommandListener('setpointlimit', $this, 'commandSetPointlimit', true, 'Setpointlimit XXX or auto'); | ||||
|  | ||||
| 		$this->updatePointLimit(); | ||||
| 	} | ||||
| @@ -126,12 +126,12 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
| 		if ($this->staticMode) { | ||||
| 			return; | ||||
| 		} | ||||
| 		$numberOfPlayers = $this->maniaControl->playerManager->getPlayerCount(); | ||||
| 		$numberOfPlayers = $this->maniaControl->getPlayerManager()->getPlayerCount(); | ||||
|  | ||||
| 		$multiplier = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_POINT_LIMIT_MULTIPLIER); | ||||
| 		$offset     = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_POINT_LIMIT_OFFSET); | ||||
| 		$minValue   = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MIN_POINT_LIMIT); | ||||
| 		$maxValue   = $this->maniaControl->settingManager->getSettingValue($this, self::SETTING_MAX_POINT_LIMIT); | ||||
| 		$multiplier = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_POINT_LIMIT_MULTIPLIER); | ||||
| 		$offset     = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_POINT_LIMIT_OFFSET); | ||||
| 		$minValue   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MIN_POINT_LIMIT); | ||||
| 		$maxValue   = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAX_POINT_LIMIT); | ||||
|  | ||||
| 		$pointLimit = $offset + $numberOfPlayers * $multiplier; | ||||
| 		if ($pointLimit < $minValue) { | ||||
| @@ -144,15 +144,15 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
|  | ||||
| 		if ($this->lastPointLimit !== $pointLimit) { | ||||
| 			try { | ||||
| 				$this->maniaControl->client->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $pointLimit)); | ||||
| 				$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $pointLimit)); | ||||
| 				$message = "Dynamic PointLimit changed to: {$pointLimit}!"; | ||||
| 				if ($this->lastPointLimit !== null) { | ||||
| 					$message .= " (From {$this->lastPointLimit})"; | ||||
| 				} | ||||
| 				$this->maniaControl->chat->sendInformation($message); | ||||
| 				$this->maniaControl->getChat()->sendInformation($message); | ||||
| 				$this->lastPointLimit = $pointLimit; | ||||
| 			} catch (GameModeException $exception) { | ||||
| 				$this->maniaControl->chat->sendExceptionToAdmins($exception); | ||||
| 				$this->maniaControl->getChat()->sendExceptionToAdmins($exception); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -166,31 +166,31 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
| 	public function commandSetPointlimit(array $chatCallback, Player $player) { | ||||
| 		$commandParts = explode(' ', $chatCallback[1][2]); | ||||
| 		if (count($commandParts) < 2) { | ||||
| 			$this->maniaControl->chat->sendUsageInfo('Example: //setpointlimit auto', $player); | ||||
| 			$this->maniaControl->getChat()->sendUsageInfo('Example: //setpointlimit auto', $player); | ||||
| 			return; | ||||
| 		} | ||||
| 		$value = strtolower($commandParts[1]); | ||||
| 		if ($value === "auto") { | ||||
| 			$this->staticMode = false; | ||||
| 			$this->maniaControl->chat->sendInformation('Enabled Dynamic PointLimit!'); | ||||
| 			$this->maniaControl->getChat()->sendInformation('Enabled Dynamic PointLimit!'); | ||||
| 			$this->updatePointLimit(); | ||||
| 		} else { | ||||
| 			if (is_numeric($value)) { | ||||
| 				$value = (int)$value; | ||||
| 				if ($value <= 0) { | ||||
| 					$this->maniaControl->chat->sendError('PointLimit needs to be greater than Zero.', $player); | ||||
| 					$this->maniaControl->getChat()->sendError('PointLimit needs to be greater than Zero.', $player); | ||||
| 					return; | ||||
| 				} | ||||
| 				try { | ||||
| 					$this->maniaControl->client->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $value)); | ||||
| 					$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $value)); | ||||
| 					$this->staticMode     = true; | ||||
| 					$this->lastPointLimit = $value; | ||||
| 					$this->maniaControl->chat->sendInformation("PointLimit changed to: {$value} (Fixed)"); | ||||
| 					$this->maniaControl->getChat()->sendInformation("PointLimit changed to: {$value} (Fixed)"); | ||||
| 				} catch (GameModeException $exception) { | ||||
| 					$this->maniaControl->chat->sendException($exception, $player); | ||||
| 					$this->maniaControl->getChat()->sendException($exception, $player); | ||||
| 				} | ||||
| 			} else { | ||||
| 				$this->maniaControl->chat->sendUsageInfo('Example: //setpointlimit 150', $player); | ||||
| 				$this->maniaControl->getChat()->sendUsageInfo('Example: //setpointlimit 150', $player); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -220,9 +220,9 @@ class DynamicPointLimitPlugin implements CallbackListener, CommandListener, Plug | ||||
| 		if ($this->staticMode && !is_null($this->lastPointLimit)) { | ||||
| 			// Refresh static point limit in case it has been reset | ||||
| 			try { | ||||
| 				$this->maniaControl->client->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $this->lastPointLimit)); | ||||
| 				$this->maniaControl->getClient()->setModeScriptSettings(array(self::SCRIPT_SETTING_MAP_POINTS_LIMIT => $this->lastPointLimit)); | ||||
| 				$message = "PointLimit fixed at {$this->lastPointLimit}."; | ||||
| 				$this->maniaControl->chat->sendInformation($message); | ||||
| 				$this->maniaControl->getChat()->sendInformation($message); | ||||
| 			} catch (GameModeException $e) { | ||||
| 				$this->lastPointLimit = null; | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user