fix: исправляем баг с версией сборки

раньше latestVersion вычислялся как currentVersion + 1
теперь честно получаем версию с сервера через PackDownloader.checkForUpdates()

так же обновили места в LaunchMenu и UpdateMenu где используется этот метод
This commit is contained in:
SashegDev
2026-05-05 08:42:51 +00:00
parent 526a24a16a
commit 1934199ba8
4 changed files with 14 additions and 10 deletions
@@ -65,13 +65,14 @@ public class InstallService {
}
PackDownloader downloader = new PackDownloader(instance);
boolean hasUpdate = downloader.checkForUpdates(instance.getServerPackName());
int serverVersion = downloader.checkForUpdates(instance.getServerPackName());
boolean hasUpdate = serverVersion > 0;
return ApiResponse.success(new UpdateCheckResult(
hasUpdate,
true,
instance.getServerVersion(),
hasUpdate ? instance.getServerVersion() + 1 : instance.getServerVersion()
serverVersion
));
} catch (Exception e) {
return ApiResponse.error("Ошибка проверки обновлений: " + e.getMessage());
@@ -351,7 +351,8 @@ public class LaunchMenu {
System.out.println(ZAnsi.cyan("Проверка обновлений для " + instance.getName()));
PackDownloader downloader = new PackDownloader(instance);
boolean hasUpdate = downloader.checkForUpdates(instance.getServerPackName());
int serverVersion = downloader.checkForUpdates(instance.getServerPackName());
boolean hasUpdate = serverVersion > 0;
if (!hasUpdate) {
System.out.println(ZAnsi.green("Сборка актуальна (v" + instance.getServerVersion() + ")"));
@@ -64,9 +64,10 @@ public class UpdateMenu {
for (Instance instance : serverInstances) {
PackDownloader downloader = new PackDownloader(instance);
try {
boolean hasUpdate = downloader.checkForUpdates(instance.getServerPackName());
int serverVersion = downloader.checkForUpdates(instance.getServerPackName());
boolean hasUpdate = serverVersion > 0;
if (hasUpdate) {
System.out.println(ZAnsi.yellow(instance.getName() + " - Есть обновление!"));
updatableInstances.add(instance);
@@ -225,15 +225,16 @@ public class PackDownloader {
/**
* Проверить наличие обновлений для серверной сборки
* @return версия на сервере, или 0 если нет обновлений
*/
public boolean checkForUpdates(String packName) throws Exception {
if (!instance.isServerPack()) return false;
public int checkForUpdates(String packName) throws Exception {
if (!instance.isServerPack()) return 0;
PackManifest manifest = getPackManifest(packName);
int serverVersion = manifest.getVersion();
int localVersion = instance.getServerVersion();
return serverVersion > localVersion;
return serverVersion > localVersion ? serverVersion : 0;
}
/**