performed code formatting

This commit is contained in:
Steffen Schröder
2014-08-05 02:17:41 +02:00
parent 98b5f132dc
commit 28d2c08936
66 changed files with 4054 additions and 1901 deletions

View File

@ -40,11 +40,14 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$this->maniaControl = $maniaControl;
// Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->getCallbackManager()
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
// Chat commands
$this->maniaControl->getCommandManager()->registerCommandListener('checkpluginsupdate', $this, 'handle_CheckPluginsUpdate', true, 'Check for Plugin Updates.');
$this->maniaControl->getCommandManager()->registerCommandListener('pluginsupdate', $this, 'handle_PluginsUpdate', true, 'Perform the Plugin Updates.');
$this->maniaControl->getCommandManager()
->registerCommandListener('checkpluginsupdate', $this, 'handle_CheckPluginsUpdate', true, 'Check for Plugin Updates.');
$this->maniaControl->getCommandManager()
->registerCommandListener('pluginsupdate', $this, 'handle_PluginsUpdate', true, 'Perform the Plugin Updates.');
}
/**
@ -54,8 +57,11 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param Player $player
*/
public function handle_CheckPluginsUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()
->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATECHECK)
) {
$this->maniaControl->getAuthenticationManager()
->sendNotAllowed($player);
return;
}
@ -70,22 +76,26 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
public function checkPluginsUpdate(Player $player = null) {
$message = 'Checking Plugins for newer Versions...';
if ($player) {
$this->maniaControl->getChat()->sendInformation($message, $player);
$this->maniaControl->getChat()
->sendInformation($message, $player);
}
Logger::log($message);
$this->maniaControl->getPluginManager()->fetchPluginList(function ($data, $error) use (&$player) {
$this->maniaControl->getPluginManager()
->fetchPluginList(function ($data, $error) use (&$player) {
if (!$data || $error) {
$message = 'Error while checking Plugins for newer Versions!';
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
}
$pluginsData = $this->parsePluginsData($data);
$pluginClasses = $this->maniaControl->getPluginManager()->getPluginClasses();
$pluginClasses = $this->maniaControl->getPluginManager()
->getPluginClasses();
$pluginUpdates = array();
foreach ($pluginClasses as $pluginClass) {
@ -101,7 +111,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$pluginUpdates[$pluginId] = $pluginData;
$message = "There is an Update of '{$pluginData->pluginName}' available! ('{$pluginClass}' - Version {$pluginData->version})";
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
}
@ -110,14 +121,16 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (empty($pluginUpdates)) {
$message = 'Plugins Update Check completed: All Plugins are up-to-date!';
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
} else {
$updatesCount = count($pluginUpdates);
$message = "Plugins Update Check completed: There are {$updatesCount} Updates available!";
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
}
@ -149,8 +162,11 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param Player $player
*/
public function handle_PluginsUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()
->checkPermission($player, UpdateManager::SETTING_PERMISSION_UPDATE)
) {
$this->maniaControl->getAuthenticationManager()
->sendNotAllowed($player);
return;
}
@ -167,7 +183,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (empty($pluginsUpdates)) {
$message = 'There are no Plugin Updates available!';
if ($player) {
$this->maniaControl->getChat()->sendInformation($message, $player);
$this->maniaControl->getChat()
->sendInformation($message, $player);
}
Logger::log($message);
return;
@ -175,15 +192,18 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$message = "Starting Plugins Updating...";
if ($player) {
$this->maniaControl->getChat()->sendInformation($message, $player);
$this->maniaControl->getChat()
->sendInformation($message, $player);
}
Logger::log($message);
$performBackup = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_PERFORM_BACKUPS);
$performBackup = $this->maniaControl->getSettingManager()
->getSettingValue($this->maniaControl->getUpdateManager(), UpdateManager::SETTING_PERFORM_BACKUPS);
if ($performBackup && !BackupUtil::performPluginsBackup()) {
$message = 'Creating Backup before Plugins Update failed!';
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
}
@ -210,7 +230,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$pluginsUpdates = $this->parsePluginsData($pluginData);
$updates = array();
$pluginClasses = $this->maniaControl->getPluginManager()->getPluginClasses();
$pluginClasses = $this->maniaControl->getPluginManager()
->getPluginClasses();
foreach ($pluginClasses as $pluginClass) {
/** @var Plugin $pluginClass */
$pluginId = $pluginClass::getId();
@ -238,13 +259,15 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
* @param bool $update
*/
private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) {
$this->maniaControl->getFileReader()->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (
$this->maniaControl->getFileReader()
->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (
&$pluginUpdateData, &$player, &$update
) {
if (!$updateFileContent || $error) {
$message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!";
if ($player) {
$this->maniaControl->getChat()->sendInformation($message, $player);
$this->maniaControl->getChat()
->sendInformation($message, $player);
}
Logger::logError($message);
return;
@ -256,7 +279,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$message = "Now {$actionVerb} '{$pluginUpdateData->pluginName}'...";
if ($player) {
$this->maniaControl->getChat()->sendInformation($message, $player);
$this->maniaControl->getChat()
->sendInformation($message, $player);
}
Logger::log($message);
@ -267,7 +291,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if (!$bytes || $bytes <= 0) {
$message = "Plugin {$actionNoun} failed: Couldn't save {$actionNoun} Zip!";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
@ -278,7 +303,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
if ($result !== true) {
$message = "Plugin {$actionNoun} failed: Couldn't open {$actionNoun} Zip! ({$result})";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
@ -295,26 +321,31 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
}
$message = "Successfully {$actionVerbDone} '{$pluginUpdateData->pluginName}'!{$messageExtra}";
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
if (!$update) {
$newPluginClasses = $this->maniaControl->getPluginManager()->loadPlugins();
$newPluginClasses = $this->maniaControl->getPluginManager()
->loadPlugins();
if (empty($newPluginClasses)) {
$message = "Loading fresh installed Plugin '{$pluginUpdateData->pluginName}' failed!";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::log($message);
} else {
$message = "Successfully loaded fresh installed Plugin '{$pluginUpdateData->pluginName}'!";
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
$this->maniaControl->getConfigurator()->showMenu($player, InstallMenu::getTitle());
$this->maniaControl->getConfigurator()
->showMenu($player, InstallMenu::getTitle());
}
}
});
@ -334,7 +365,8 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
}
$login = $callback[1][1];
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
$player = $this->maniaControl->getPlayerManager()
->getPlayer($login);
if ($update) {
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
@ -346,24 +378,28 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
$this->installPlugin($pluginUpdateData, $player, true);
} else {
$message = 'Error loading Plugin Update Data!';
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
}
} else {
$pluginId = substr($actionId, strlen(InstallMenu::ACTION_PREFIX_INSTALL_PLUGIN));
$url = ManiaControl::URL_WEBSERVICE . 'plugins/' . $pluginId;
$this->maniaControl->getFileReader()->loadFile($url, function ($data, $error) use (&$player) {
$this->maniaControl->getFileReader()
->loadFile($url, function ($data, $error) use (&$player) {
if ($error || !$data) {
$message = "Error loading Plugin Install Data! {$error}";
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
return;
}
$data = json_decode($data);
if (!$data) {
$message = "Error loading Plugin Install Data! {$error}";
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
return;
}

View File

@ -60,25 +60,38 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$this->maniaControl = $maniaControl;
// Settings
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE_UPDATECHECK, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTO_UPDATE, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 1);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, $this->getUpdateChannels());
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_ENABLE_UPDATECHECK, true);
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_AUTO_UPDATE, true);
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_UPDATECHECK_INTERVAL, 1);
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_UPDATECHECK_CHANNEL, $this->getUpdateChannels());
$this->maniaControl->getSettingManager()
->initSetting($this, self::SETTING_PERFORM_BACKUPS, true);
// Callbacks
$updateInterval = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_UPDATECHECK_INTERVAL);
$this->maniaControl->getTimerManager()->registerTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60 * $updateInterval);
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
$updateInterval = $this->maniaControl->getSettingManager()
->getSettingValue($this, self::SETTING_UPDATECHECK_INTERVAL);
$this->maniaControl->getTimerManager()
->registerTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60 * $updateInterval);
$this->maniaControl->getCallbackManager()
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
$this->maniaControl->getCallbackManager()
->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
// Permissions
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_UPDATECHECK, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$this->maniaControl->getAuthenticationManager()
->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
$this->maniaControl->getAuthenticationManager()
->definePermissionLevel(self::SETTING_PERMISSION_UPDATECHECK, AuthenticationManager::AUTH_LEVEL_MODERATOR);
// Chat commands
$this->maniaControl->getCommandManager()->registerCommandListener('checkupdate', $this, 'handle_CheckUpdate', true, 'Checks if there is a core update.');
$this->maniaControl->getCommandManager()->registerCommandListener('coreupdate', $this, 'handle_CoreUpdate', true, 'Performs the core update.');
$this->maniaControl->getCommandManager()
->registerCommandListener('checkupdate', $this, 'handle_CheckUpdate', true, 'Checks if there is a core update.');
$this->maniaControl->getCommandManager()
->registerCommandListener('coreupdate', $this, 'handle_CoreUpdate', true, 'Performs the core update.');
// Children
$this->pluginUpdateManager = new PluginUpdateManager($maniaControl);
@ -107,7 +120,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Perform Hourly Update Check
*/
public function hourlyUpdateCheck() {
$updateCheckEnabled = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_UPDATECHECK);
$updateCheckEnabled = $this->maniaControl->getSettingManager()
->getSettingValue($this, self::SETTING_ENABLE_UPDATECHECK);
if (!$updateCheckEnabled) {
$this->setCoreUpdateData();
} else {
@ -140,7 +154,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$updateChannel = $this->getCurrentUpdateChannelSetting();
$url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel;
$this->maniaControl->getFileReader()->loadFile($url, function ($dataJson, $error) use (&$function) {
$this->maniaControl->getFileReader()
->loadFile($url, function ($dataJson, $error) use (&$function) {
if ($error) {
Logger::logError('Error on UpdateCheck: ' . $error);
return;
@ -161,7 +176,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @return string
*/
public function getCurrentUpdateChannelSetting() {
$updateChannel = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_UPDATECHECK_CHANNEL);
$updateChannel = $this->maniaControl->getSettingManager()
->getSettingValue($this, self::SETTING_UPDATECHECK_CHANNEL);
$updateChannel = strtolower($updateChannel);
if (!in_array($updateChannel, $this->getUpdateChannels())) {
$updateChannel = self::CHANNEL_RELEASE;
@ -259,7 +275,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
return false;
}
$version = $this->maniaControl->getClient()->getVersion();
$version = $this->maniaControl->getClient()
->getVersion();
if ($updateData->minDedicatedBuild > $version->build) {
// Server not compatible
return false;
@ -272,7 +289,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* Check if an automatic Update should be performed
*/
public function checkAutoUpdate() {
$autoUpdate = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_AUTO_UPDATE);
$autoUpdate = $this->maniaControl->getSettingManager()
->getSettingValue($this, self::SETTING_AUTO_UPDATE);
if (!$autoUpdate) {
// Auto update turned off
return;
@ -281,7 +299,9 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
// No update available
return;
}
if ($this->maniaControl->getPlayerManager()->getPlayerCount(false) > 0) {
if ($this->maniaControl->getPlayerManager()
->getPlayerCount(false) > 0
) {
// Server not empty
return;
}
@ -299,7 +319,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if (!$this->coreUpdateData) {
$message = 'Update failed: No update Data available!';
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return false;
@ -311,39 +332,45 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if (!FileUtil::checkWritePermissions($directories)) {
$message = 'Update not possible: Incorrect File System Permissions!';
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return false;
}
$performBackup = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERFORM_BACKUPS);
$performBackup = $this->maniaControl->getSettingManager()
->getSettingValue($this, self::SETTING_PERFORM_BACKUPS);
if ($performBackup && !BackupUtil::performFullBackup()) {
$message = 'Creating Backup before Update failed!';
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
}
$updateData = $this->coreUpdateData;
$this->maniaControl->getFileReader()->loadFile($updateData->url, function ($updateFileContent, $error) use (
$this->maniaControl->getFileReader()
->loadFile($updateData->url, function ($updateFileContent, $error) use (
$updateData, &$player
) {
if (!$updateFileContent || $error) {
$message = "Update failed: Couldn't load Update zip! {$error}";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
}
$tempDir = FileUtil::getTempFolder();
$tempDir = FileUtil::getTempFolder();
if (!$tempDir) {
$message = "Update failed: Can't save Update zip!";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
@ -354,7 +381,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if (!$bytes || $bytes <= 0) {
$message = "Update failed: Couldn't save Update zip!";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
return;
@ -365,7 +393,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if ($result !== true) {
$message = "Update failed: Couldn't open Update Zip. ({$result})";
if ($player) {
$this->maniaControl->getChat()->sendError($message, $player);
$this->maniaControl->getChat()
->sendError($message, $player);
}
Logger::logError($message);
unlink($updateFileName);
@ -382,7 +411,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$message = 'Update finished!';
if ($player) {
$this->maniaControl->getChat()->sendSuccess($message, $player);
$this->maniaControl->getChat()
->sendSuccess($message, $player);
}
Logger::log($message);
@ -415,14 +445,18 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
return;
}
// Announce available update
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) {
if (!$this->maniaControl->getAuthenticationManager()
->checkPermission($player, self::SETTING_PERMISSION_UPDATE)
) {
return;
}
if ($this->isNightlyUpdateChannel()) {
$this->maniaControl->getChat()->sendSuccess('New Nightly Build (' . $this->coreUpdateData->releaseDate . ') available!', $player->login);
$this->maniaControl->getChat()
->sendSuccess('New Nightly Build (' . $this->coreUpdateData->releaseDate . ') available!', $player->login);
} else {
$this->maniaControl->getChat()->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login);
$this->maniaControl->getChat()
->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login);
}
}
@ -442,19 +476,24 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @param Player $player
*/
public function handle_CheckUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATECHECK)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()
->checkPermission($player, self::SETTING_PERMISSION_UPDATECHECK)
) {
$this->maniaControl->getAuthenticationManager()
->sendNotAllowed($player);
return;
}
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
if (!$this->checkUpdateData($updateData)) {
$this->maniaControl->getChat()->sendInformation('No Update available!', $player->login);
$this->maniaControl->getChat()
->sendInformation('No Update available!', $player->login);
return;
}
if (!$this->checkUpdateDataBuildVersion($updateData)) {
$this->maniaControl->getChat()->sendError("Please update Your Server to '{$updateData->minDedicatedBuild}' in order to receive further Updates!", $player->login);
$this->maniaControl->getChat()
->sendError("Please update Your Server to '{$updateData->minDedicatedBuild}' in order to receive further Updates!", $player->login);
return;
}
@ -463,16 +502,20 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$buildDate = $this->getNightlyBuildDate();
if ($buildDate) {
if ($updateData->isNewerThan($buildDate)) {
$this->maniaControl->getChat()->sendInformation("No new Build available! (Current Build: '{$buildDate}')", $player->login);
$this->maniaControl->getChat()
->sendInformation("No new Build available! (Current Build: '{$buildDate}')", $player->login);
return;
} else {
$this->maniaControl->getChat()->sendSuccess("New Nightly Build ({$updateData->releaseDate}) available! (Current Build: '{$buildDate}')", $player->login);
$this->maniaControl->getChat()
->sendSuccess("New Nightly Build ({$updateData->releaseDate}) available! (Current Build: '{$buildDate}')", $player->login);
}
} else {
$this->maniaControl->getChat()->sendSuccess("New Nightly Build ('{$updateData->releaseDate}') available!", $player->login);
$this->maniaControl->getChat()
->sendSuccess("New Nightly Build ('{$updateData->releaseDate}') available!", $player->login);
}
} else {
$this->maniaControl->getChat()->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
$this->maniaControl->getChat()
->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
}
$this->coreUpdateData = $updateData;
@ -486,18 +529,23 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
* @param Player $player
*/
public function handle_CoreUpdate(array $chatCallback, Player $player) {
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_UPDATE)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
if (!$this->maniaControl->getAuthenticationManager()
->checkPermission($player, self::SETTING_PERMISSION_UPDATE)
) {
$this->maniaControl->getAuthenticationManager()
->sendNotAllowed($player);
return;
}
$this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) {
if (!$updateData) {
$this->maniaControl->getChat()->sendError('Update is currently not possible!', $player);
$this->maniaControl->getChat()
->sendError('Update is currently not possible!', $player);
return;
}
if (!$this->checkUpdateDataBuildVersion($updateData)) {
$this->maniaControl->getChat()->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player);
$this->maniaControl->getChat()
->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player);
return;
}