refactor codestyle (chaining)
This commit is contained in:
@ -46,12 +46,10 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_INSTALL_PLUGINS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_INSTALL_PLUGINS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,9 +92,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Pagers
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->add($pagerPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)
|
||||
->setSize($pagerSize, $pagerSize)
|
||||
->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
$pagerPrev->setPosition($width * 0.39, $height * -0.44, 2)->setSize($pagerSize, $pagerSize)->setSubStyle($pagerPrev::SUBSTYLE_ArrowPrev);
|
||||
|
||||
$pagerNext = clone $pagerPrev;
|
||||
$frame->add($pagerNext);
|
||||
@ -104,31 +100,18 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
|
||||
$pageCountLabel = new Label_Text();
|
||||
$frame->add($pageCountLabel);
|
||||
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)
|
||||
->setPosition($width * 0.35, $height * -0.44, 1)
|
||||
->setStyle($pageCountLabel::STYLE_TextTitle1)
|
||||
->setTextSize(2);
|
||||
$pageCountLabel->setHAlign($pageCountLabel::RIGHT)->setPosition($width * 0.35, $height * -0.44, 1)->setStyle($pageCountLabel::STYLE_TextTitle1)->setTextSize(2);
|
||||
|
||||
$paging->addButton($pagerNext)
|
||||
->addButton($pagerPrev)
|
||||
->setLabel($pageCountLabel);
|
||||
$paging->addButton($pagerNext)->addButton($pagerPrev)->setLabel($pageCountLabel);
|
||||
|
||||
// Info tooltip
|
||||
$infoTooltipLabel = new Label();
|
||||
$frame->add($infoTooltipLabel);
|
||||
$infoTooltipLabel->setAlign($infoTooltipLabel::LEFT, $infoTooltipLabel::TOP)
|
||||
->setPosition($width * -0.45, $height * -0.22)
|
||||
->setSize($width * 0.7, $entryHeight)
|
||||
->setTextSize(1)
|
||||
->setTranslate(true)
|
||||
->setVisible(false)
|
||||
->setAutoNewLine(true)
|
||||
->setMaxLines(5);
|
||||
$infoTooltipLabel->setAlign($infoTooltipLabel::LEFT, $infoTooltipLabel::TOP)->setPosition($width * -0.45, $height * -0.22)->setSize($width * 0.7, $entryHeight)->setTextSize(1)->setTranslate(true)->setVisible(false)->setAutoNewLine(true)->setMaxLines(5);
|
||||
|
||||
// List plugins
|
||||
foreach ($pluginList as $plugin) {
|
||||
if ($this->maniaControl->getPluginManager()
|
||||
->isPluginIdInstalled($plugin->id)
|
||||
if ($this->maniaControl->getPluginManager()->isPluginIdInstalled($plugin->id)
|
||||
) {
|
||||
// Already installed -> Skip
|
||||
continue;
|
||||
@ -148,12 +131,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
|
||||
$nameLabel = new Label_Text();
|
||||
$pluginFrame->add($nameLabel);
|
||||
$nameLabel->setHAlign($nameLabel::LEFT)
|
||||
->setX($width * -0.46)
|
||||
->setSize($width * 0.62, $entryHeight)
|
||||
->setStyle($nameLabel::STYLE_TextCardSmall)
|
||||
->setTextSize(2)
|
||||
->setText($plugin->name);
|
||||
$nameLabel->setHAlign($nameLabel::LEFT)->setX($width * -0.46)->setSize($width * 0.62, $entryHeight)->setStyle($nameLabel::STYLE_TextCardSmall)->setTextSize(2)->setText($plugin->name);
|
||||
|
||||
$description = "Author: {$plugin->author}\nVersion: {$plugin->currentVersion->version}\nDesc: {$plugin->description}";
|
||||
$nameLabel->addTooltipLabelFeature($infoTooltipLabel, $description);
|
||||
@ -162,11 +140,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Incompatibility label
|
||||
$infoLabel = new Label_Text();
|
||||
$pluginFrame->add($infoLabel);
|
||||
$infoLabel->setHAlign($infoLabel::RIGHT)
|
||||
->setX($width * 0.47)
|
||||
->setSize($width * 0.33, $entryHeight)
|
||||
->setTextSize(1)
|
||||
->setTextColor('f30');
|
||||
$infoLabel->setHAlign($infoLabel::RIGHT)->setX($width * 0.47)->setSize($width * 0.33, $entryHeight)->setTextSize(1)->setTextColor('f30');
|
||||
if ($plugin->currentVersion->min_mc_version > ManiaControl::VERSION) {
|
||||
$infoLabel->setText("Needs at least MC-Version '{$plugin->currentVersion->min_mc_version}'");
|
||||
} else {
|
||||
@ -176,21 +150,14 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
// Install button
|
||||
$installButton = new Label_Button();
|
||||
$pluginFrame->add($installButton);
|
||||
$installButton->setHAlign($installButton::RIGHT)
|
||||
->setX($width * 0.47)
|
||||
->setStyle($installButton::STYLE_CardButtonSmall)
|
||||
->setText('Install')
|
||||
->setTranslate(true)
|
||||
->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
|
||||
$installButton->setHAlign($installButton::RIGHT)->setX($width * 0.47)->setStyle($installButton::STYLE_CardButtonSmall)->setText('Install')->setTranslate(true)->setAction(self::ACTION_PREFIX_INSTALL_PLUGIN . $plugin->id);
|
||||
}
|
||||
|
||||
if ($plugin->currentVersion->verified > 0) {
|
||||
// Suggested quad
|
||||
$suggestedQuad = new Quad_Icons64x64_1();
|
||||
$pluginFrame->add($suggestedQuad);
|
||||
$suggestedQuad->setPosition($width * 0.45, $entryHeight * 0.12, 2)
|
||||
->setSize(4, 4)
|
||||
->setSubStyle($suggestedQuad::SUBSTYLE_StateSuggested);
|
||||
$suggestedQuad->setPosition($width * 0.45, $entryHeight * 0.12, 2)->setSize(4, 4)->setSubStyle($suggestedQuad::SUBSTYLE_StateSuggested);
|
||||
}
|
||||
|
||||
$posY -= $entryHeight;
|
||||
@ -211,19 +178,11 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
|
||||
$infoLabel = new Label_Text();
|
||||
$frame->add($infoLabel);
|
||||
$infoLabel->setVAlign($infoLabel::BOTTOM)
|
||||
->setY(2)
|
||||
->setSize(100, 25)
|
||||
->setTextColor('f30')
|
||||
->setTranslate(true)
|
||||
->setText('An error occurred. Please try again later.');
|
||||
$infoLabel->setVAlign($infoLabel::BOTTOM)->setY(2)->setSize(100, 25)->setTextColor('f30')->setTranslate(true)->setText('An error occurred. Please try again later.');
|
||||
|
||||
$refreshQuad = new Quad_Icons64x64_1();
|
||||
$frame->add($refreshQuad);
|
||||
$refreshQuad->setY(-4)
|
||||
->setSize(8, 8)
|
||||
->setSubStyle($refreshQuad::SUBSTYLE_Refresh)
|
||||
->setAction(self::ACTION_REFRESH_LIST);
|
||||
$refreshQuad->setY(-4)->setSize(8, 8)->setSubStyle($refreshQuad::SUBSTYLE_Refresh)->setAction(self::ACTION_REFRESH_LIST);
|
||||
|
||||
return $frame;
|
||||
}
|
||||
@ -238,10 +197,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
|
||||
$infoLabel = new Label_Text();
|
||||
$frame->add($infoLabel);
|
||||
$infoLabel->setSize(100, 50)
|
||||
->setTextColor('0f3')
|
||||
->setTranslate(true)
|
||||
->setText('No other plugins available.');
|
||||
$infoLabel->setSize(100, 50)->setTextColor('0f3')->setTranslate(true)->setText('No other plugins available.');
|
||||
|
||||
return $frame;
|
||||
}
|
||||
@ -277,7 +233,6 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handleRefreshListAction(array $actionCallback, Player $player) {
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,10 @@ class PluginManager {
|
||||
$this->initTables();
|
||||
|
||||
$this->pluginMenu = new PluginMenu($maniaControl);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->addMenu($this->pluginMenu);
|
||||
$this->maniaControl->getConfigurator()->addMenu($this->pluginMenu);
|
||||
|
||||
$this->pluginInstallMenu = new InstallMenu($maniaControl);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->addMenu($this->pluginInstallMenu);
|
||||
$this->maniaControl->getConfigurator()->addMenu($this->pluginInstallMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,8 +62,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginsTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLUGINS . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`className` varchar(100) NOT NULL,
|
||||
@ -145,28 +142,22 @@ class PluginManager {
|
||||
$plugin->unload();
|
||||
|
||||
if ($plugin instanceof CallbackListener) {
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->unregisterCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->unregisterScriptCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()->unregisterCallbackListener($plugin);
|
||||
$this->maniaControl->getCallbackManager()->unregisterScriptCallbackListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof CommandListener) {
|
||||
$this->maniaControl->getCommandManager()
|
||||
->unregisterCommandListener($plugin);
|
||||
$this->maniaControl->getCommandManager()->unregisterCommandListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof ManialinkPageAnswerListener) {
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->unregisterManialinkPageAnswerListener($plugin);
|
||||
$this->maniaControl->getManialinkManager()->unregisterManialinkPageAnswerListener($plugin);
|
||||
}
|
||||
if ($plugin instanceof TimerListener) {
|
||||
$this->maniaControl->getTimerManager()
|
||||
->unregisterTimerListenings($plugin);
|
||||
$this->maniaControl->getTimerManager()->unregisterTimerListenings($plugin);
|
||||
}
|
||||
|
||||
$this->savePluginStatus($pluginClass, false);
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_UNLOADED, $pluginClass, $plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -204,8 +195,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function savePluginStatus($className, $active) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginStatusQuery = "INSERT INTO `" . self::TABLE_PLUGINS . "` (
|
||||
`className`,
|
||||
`active`
|
||||
@ -349,8 +339,7 @@ class PluginManager {
|
||||
* @return bool
|
||||
*/
|
||||
public function getSavedPluginStatus($className) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$pluginStatusQuery = "SELECT `active` FROM `" . self::TABLE_PLUGINS . "`
|
||||
WHERE `className` = ?;";
|
||||
$pluginStatement = $mysqli->prepare($pluginStatusQuery);
|
||||
@ -401,8 +390,7 @@ class PluginManager {
|
||||
$plugin->load($this->maniaControl);
|
||||
} catch (\Exception $e) {
|
||||
$message = "Error during Plugin Activation of '{$pluginClass}': '{$e->getMessage()}'";
|
||||
$this->maniaControl->getChat()
|
||||
->sendError($message, $adminLogin);
|
||||
$this->maniaControl->getChat()->sendError($message, $adminLogin);
|
||||
Logger::logError($message);
|
||||
$this->savePluginStatus($pluginClass, false);
|
||||
return false;
|
||||
@ -411,8 +399,7 @@ class PluginManager {
|
||||
$this->activePlugins[$pluginClass] = $plugin;
|
||||
$this->savePluginStatus($pluginClass, true);
|
||||
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLUGIN_LOADED, $pluginClass, $plugin);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLUGIN_LOADED, $pluginClass, $plugin);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -487,10 +474,9 @@ class PluginManager {
|
||||
*/
|
||||
public function fetchPluginList(callable $function) {
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||
$this->maniaControl->getFileReader()
|
||||
->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||
$data = json_decode($dataJson);
|
||||
call_user_func($function, $data, $error);
|
||||
});
|
||||
$this->maniaControl->getFileReader()->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||
$data = json_decode($dataJson);
|
||||
call_user_func($function, $data, $error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -61,14 +61,11 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_BACK_TO_PLUGINS, $this, 'backToPlugins');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_BACK_TO_PLUGINS, $this, 'backToPlugins');
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,8 +83,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
*/
|
||||
public function backToPlugins($callback, Player $player) {
|
||||
$player->destroyCache($this, self::CACHE_SETTING_CLASS);
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,8 +94,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$script->addFeature($paging);
|
||||
$frame = new Frame();
|
||||
|
||||
$pluginClasses = $this->maniaControl->getPluginManager()
|
||||
->getPluginClasses();
|
||||
$pluginClasses = $this->maniaControl->getPluginManager()->getPluginClasses();
|
||||
|
||||
// Config
|
||||
$pagerSize = 9.;
|
||||
@ -140,9 +135,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
// Display normal Plugin List
|
||||
// Plugin pages
|
||||
$posY = 0.;
|
||||
$pluginUpdates = $this->maniaControl->getUpdateManager()
|
||||
->getPluginUpdateManager()
|
||||
->getPluginsUpdates();
|
||||
$pluginUpdates = $this->maniaControl->getUpdateManager()->getPluginUpdateManager()->getPluginsUpdates();
|
||||
|
||||
usort($pluginClasses, function ($pluginClassA, $pluginClassB) {
|
||||
/** @var Plugin $pluginClassA */
|
||||
@ -160,8 +153,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
$posY = $height * 0.41;
|
||||
}
|
||||
|
||||
$active = $this->maniaControl->getPluginManager()
|
||||
->isPluginActive($pluginClass);
|
||||
$active = $this->maniaControl->getPluginManager()->isPluginActive($pluginClass);
|
||||
|
||||
$pluginFrame = new Frame();
|
||||
$pageFrame->add($pluginFrame);
|
||||
@ -263,8 +255,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
*/
|
||||
private function getPluginSettingsMenu(Frame $frame, $width, $height, Paging $paging, Player $player, $settingClass) {
|
||||
// TODO: centralize menu code to use by mc settings and plugin settings
|
||||
$settings = $this->maniaControl->getSettingManager()
|
||||
->getSettingsByClass($settingClass);
|
||||
$settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass);
|
||||
|
||||
$pageSettingsMaxCount = 11;
|
||||
$posY = 0;
|
||||
@ -357,8 +348,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
return;
|
||||
}
|
||||
@ -374,28 +364,22 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
if ($enable) {
|
||||
$pluginClass = substr($actionId, strlen(self::ACTION_PREFIX_ENABLEPLUGIN));
|
||||
/** @var Plugin $pluginClass */
|
||||
$activated = $this->maniaControl->getPluginManager()
|
||||
->activatePlugin($pluginClass, $player->login);
|
||||
$activated = $this->maniaControl->getPluginManager()->activatePlugin($pluginClass, $player->login);
|
||||
if ($activated) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($pluginClass::getName() . ' activated!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($pluginClass::getName() . ' activated!', $player);
|
||||
Logger::logInfo("{$player->login} activated '{$pluginClass}'!", true);
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error activating ' . $pluginClass::getName() . '!', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error activating ' . $pluginClass::getName() . '!', $player);
|
||||
}
|
||||
} else if ($disable) {
|
||||
$pluginClass = substr($actionId, strlen(self::ACTION_PREFIX_DISABLEPLUGIN));
|
||||
/** @var Plugin $pluginClass */
|
||||
$deactivated = $this->maniaControl->getPluginManager()
|
||||
->deactivatePlugin($pluginClass);
|
||||
$deactivated = $this->maniaControl->getPluginManager()->deactivatePlugin($pluginClass);
|
||||
if ($deactivated) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess($pluginClass::getName() . ' deactivated!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($pluginClass::getName() . ' deactivated!', $player);
|
||||
Logger::logInfo("{$player->login} deactivated '{$pluginClass}'!", true);
|
||||
} else {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error deactivating ' . $pluginClass::getName() . '!', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error deactivating ' . $pluginClass::getName() . '!', $player);
|
||||
}
|
||||
} else if ($settings) {
|
||||
// Open Settings Menu
|
||||
@ -404,19 +388,16 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
}
|
||||
|
||||
// Reopen the Menu
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Configurators\ConfiguratorMenu::saveConfigData()
|
||||
*/
|
||||
public function saveConfigData(array $configData, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_PLUGIN_SETTINGS)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) {
|
||||
@ -427,8 +408,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
|
||||
foreach ($configData[3] as $settingData) {
|
||||
$settingIndex = (int)substr($settingData['Name'], $prefixLength);
|
||||
$settingObject = $this->maniaControl->getSettingManager()
|
||||
->getSettingObjectByIndex($settingIndex);
|
||||
$settingObject = $this->maniaControl->getSettingManager()->getSettingObjectByIndex($settingIndex);
|
||||
if (!$settingObject) {
|
||||
continue;
|
||||
}
|
||||
@ -438,15 +418,12 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns
|
||||
}
|
||||
|
||||
$settingObject->value = $settingData['Value'];
|
||||
$this->maniaControl->getSettingManager()
|
||||
->saveSetting($settingObject);
|
||||
$this->maniaControl->getSettingManager()->saveSetting($settingObject);
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Plugin Settings saved!', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('Plugin Settings saved!', $player);
|
||||
|
||||
// Reopen the Menu
|
||||
$this->maniaControl->getConfigurator()
|
||||
->showMenu($player, $this);
|
||||
$this->maniaControl->getConfigurator()->showMenu($player, $this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user