fixed //checkupdate
This commit is contained in:
parent
200f199c06
commit
ab375e636e
@ -41,7 +41,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
* Private Properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
/** @var UpdateData $coreUpdateData */
|
||||
/**
|
||||
*
|
||||
* @var UpdateData $coreUpdateData
|
||||
*/
|
||||
private $coreUpdateData = null;
|
||||
private $currentBuildDate = "";
|
||||
|
||||
@ -105,7 +108,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$updateChannel = $maniaControl->settingManager->getSetting($self, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
|
||||
if ($updateChannel != UpdateManager::CHANNEL_NIGHTLY) {
|
||||
$maniaControl->log('New ManiaControl Version ' . $updateData->version . ' available!');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$maniaControl->log('New Nightly Build (' . $updateData->releaseDate . ') available!');
|
||||
}
|
||||
$self->setCoreUpdateData($updateData);
|
||||
@ -134,7 +138,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
||||
if ($updateChannel != self::CHANNEL_NIGHTLY) {
|
||||
$this->maniaControl->chat->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$this->maniaControl->chat->sendSuccess('New Nightly Build (' . $this->coreUpdateData->releaseDate . ') available!', $player->login);
|
||||
}
|
||||
}
|
||||
@ -178,7 +183,6 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$this->performCoreUpdate($this->coreUpdateData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle //checkupdate command
|
||||
*
|
||||
@ -191,27 +195,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
return;
|
||||
}
|
||||
$updateChannel = $this->maniaControl->settingManager->getSetting($this, self::SETTING_UPDATECHECK_CHANNEL);
|
||||
if ($updateChannel != self::CHANNEL_NIGHTLY) {
|
||||
// Check update and send result message
|
||||
$self = $this;
|
||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData) use (&$self, &$player) {
|
||||
if (!$updateData) {
|
||||
$self->maniaControl->chat->sendInformation('No Update available!', $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$version = $self->maniaControl->client->getVersion();
|
||||
if ($updateData->minDedicatedBuild > $version->build) {
|
||||
$self->maniaControl->chat->sendError("No new Build for this Server-version available!", $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$self->maniaControl->chat->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
|
||||
});
|
||||
} else {
|
||||
if ($updateChannel === self::CHANNEL_NIGHTLY) {
|
||||
// Special nightly channel updating
|
||||
$self = $this;
|
||||
$this->checkCoreUpdateAsync(function (UpdateData $updateData) use (&$self, &$player) {
|
||||
$this->checkCoreUpdateAsync(function ($updateData) use(&$self, &$player) {
|
||||
if (!$updateData) {
|
||||
$self->maniaControl->chat->sendInformation('No Update available!', $player->login);
|
||||
return;
|
||||
@ -231,11 +218,32 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
return;
|
||||
}
|
||||
$self->maniaControl->chat->sendSuccess('New Nightly Build (' . $updateData->releaseDate . ') available, current build: ' . $self->currentBuildDate . '!', $player->login);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self->maniaControl->chat->sendSuccess('New Nightly Build (' . $updateData->releaseDate . ') available!', $player->login);
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
else {
|
||||
// Check update and send result message
|
||||
$self = $this;
|
||||
$this->checkCoreUpdateAsync(function ($updateData) use(&$self, &$player) {
|
||||
|
||||
if (!$updateData) {
|
||||
$self->maniaControl->chat->sendInformation('No Update available!', $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$version = $self->maniaControl->client->getVersion();
|
||||
|
||||
if ($updateData->minDedicatedBuild > $version->build) {
|
||||
$self->maniaControl->chat->sendError("No new Build for this Server-version available!", $player->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$self->maniaControl->chat->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,7 +263,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$pluginClass = substr($actionId, strlen(PluginMenu::ACTION_PREFIX_UPDATEPLUGIN));
|
||||
if ($pluginClass == 'All') {
|
||||
$this->checkPluginsUpdate($player);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$newUpdate = $this->checkPluginUpdate($pluginClass);
|
||||
if ($newUpdate != false) {
|
||||
$newUpdate->pluginClass = $pluginClass;
|
||||
@ -404,7 +413,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
foreach ($outdatedPlugins as $plugin) {
|
||||
$self->updatePlugin($plugin, $player);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$self->maniaControl->log('[UPDATE] Checking plugins: COMPLETE, all plugins are up-to-date!');
|
||||
if ($player) {
|
||||
$self->maniaControl->chat->sendInformation('Checking plugins: COMPLETE, all plugins are up-to-date!', $player->login);
|
||||
@ -423,7 +433,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
if (is_object($pluginClass)) {
|
||||
$pluginClass = get_class($pluginClass);
|
||||
}
|
||||
/** @var Plugin $pluginClass */
|
||||
/**
|
||||
*
|
||||
* @var Plugin $pluginClass
|
||||
*/
|
||||
$pluginId = $pluginClass::getId();
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins?id=' . $pluginId;
|
||||
$dataJson = FileUtil::loadFile($url);
|
||||
@ -459,7 +472,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
$pluginsWS[$plugin->id] = $plugin;
|
||||
}
|
||||
|
||||
/** @var Plugin $pluginClass */
|
||||
/**
|
||||
*
|
||||
* @var Plugin $pluginClass
|
||||
*/
|
||||
foreach ($this->maniaControl->pluginManager->getPluginClasses() as $pluginClass) {
|
||||
$pluginId = $pluginClass::getId();
|
||||
if (array_key_exists($pluginId, $pluginsWS)) {
|
||||
@ -602,7 +618,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var Plugin $className */
|
||||
/**
|
||||
*
|
||||
* @var Plugin $className
|
||||
*/
|
||||
$self->maniaControl->pluginManager->addPluginClass($className);
|
||||
$className::prepare($self->maniaControl);
|
||||
|
||||
@ -641,7 +660,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
*/
|
||||
private function checkCoreUpdateAsync($function, $ignoreVersion = false) {
|
||||
$updateChannel = $this->getCurrentUpdateChannelSetting();
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'versions?update=1¤t=1&channel=' . $updateChannel;
|
||||
$url = ManiaControl::URL_WEBSERVICE . 'versions?current=1&channel=' . $updateChannel;
|
||||
|
||||
$this->maniaControl->fileReader->loadFile($url, function ($dataJson, $error) use(&$function, $ignoreVersion) {
|
||||
$versions = json_decode($dataJson);
|
||||
@ -650,10 +669,11 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
|
||||
}
|
||||
$updateData = new UpdateData($versions[0]);
|
||||
if (!$ignoreVersion && $updateData->version <= ManiaControl::VERSION) {
|
||||
return;
|
||||
call_user_func($function, null);
|
||||
}
|
||||
|
||||
else {
|
||||
call_user_func($function, $updateData);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user