code refactoring
This commit is contained in:
@ -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');
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user