downloadLibraries method

  1. @override
Future<void> downloadLibraries()
override

Downloads required libraries for Minecraft.

Implementation

@override
Future<void> downloadLibraries() async {
  _librariesCompleter = Completer<void>();
  _activeCompleters.add(_librariesCompleter!);

  try {
    final versionId = _profileManager.activeProfile.lastVersionId;
    await beforeDownloadLibraries(versionId);
    final versionInfo = await fetchVersionManifest(versionId);

    if (versionInfo == null) {
      throw Exception('Failed to get version info for $versionId');
    }

    await _classpathManager.downloadLibraries(versionInfo);
    _librariesCompleter!.complete();
    await afterDownloadLibraries(versionId);
  } catch (e) {
    debugPrint('Error downloading libraries: $e');
    _librariesCompleter!.completeError(
      Exception('Failed to download libraries: $e'),
    );
    throw Exception('Failed to download libraries: $e');
  }
}