code refactoring

This commit is contained in:
Steffen Schröder
2014-05-02 18:21:38 +02:00
parent fa5752d9ce
commit ac5bbbeafa
11 changed files with 77 additions and 70 deletions

View File

@ -242,6 +242,14 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis
private function installPlugin(PluginUpdateData $pluginUpdateData, Player $player = null, $update = false) {
$self = $this;
$this->maniaControl->fileReader->loadFile($pluginUpdateData->url, function ($updateFileContent, $error) use (&$self, &$pluginUpdateData, &$player, &$update) {
if (!$updateFileContent || $error) {
$message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!";
if ($player) {
$self->maniaControl->chat->sendInformation($message, $player);
}
$self->maniaControl->log($message);
return;
}
$actionNoun = ($update ? 'Update' : 'Install');
$actionVerb = ($update ? 'Updating' : 'Installing');
$actionVerbDone = ($update ? 'updated' : 'installed');

View File

@ -303,6 +303,15 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$self = $this;
$this->maniaControl->fileReader->loadFile($this->coreUpdateData->url, function ($updateFileContent, $error) use (&$self, &$updateData, &$player) {
if (!$updateFileContent || !$error) {
$message = "Update failed: Couldn't load Update zip!";
if ($player) {
$self->maniaControl->chat->sendError($message, $player);
}
logMessage($message);
return;
}
$tempDir = FileUtil::getTempFolder();
$updateFileName = $tempDir . basename($updateData->url);