diff --git a/Natives/DownloadProgressViewController.m b/Natives/DownloadProgressViewController.m index c2a4ab089f..cb37df7e3b 100644 --- a/Natives/DownloadProgressViewController.m +++ b/Natives/DownloadProgressViewController.m @@ -61,7 +61,6 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } else if (context == TotalProgressObserverContext) { dispatch_async(dispatch_get_main_queue(), ^{ self.title = [NSString stringWithFormat:@"(%@) %@", progress.localizedAdditionalDescription, progress.localizedDescription]; - static dispatch_once_t once; if (self.needsReloadData) { [self.tableView reloadData]; } diff --git a/Natives/MinecraftResourceDownloadTask.m b/Natives/MinecraftResourceDownloadTask.m index 05e1ec2bb8..f80af02aa3 100644 --- a/Natives/MinecraftResourceDownloadTask.m +++ b/Natives/MinecraftResourceDownloadTask.m @@ -2,7 +2,6 @@ #import "authenticator/BaseAuthenticator.h" #import "AFNetworking.h" -#import "AFURLSessionOperation.h" #import "LauncherNavigationController.h" #import "LauncherPreferences.h" #import "MinecraftResourceDownloadTask.h" diff --git a/Natives/MinecraftResourceUtils.m b/Natives/MinecraftResourceUtils.m index 0b99d5fa64..634f617cd7 100644 --- a/Natives/MinecraftResourceUtils.m +++ b/Natives/MinecraftResourceUtils.m @@ -1,8 +1,6 @@ #include #import "authenticator/BaseAuthenticator.h" -#import "AFNetworking.h" -#import "AFURLSessionOperation.h" #import "LauncherNavigationController.h" #import "LauncherPreferences.h" #import "MinecraftResourceUtils.h" diff --git a/Natives/installer/ForgeInstallViewController.m b/Natives/installer/ForgeInstallViewController.m index 027d4c85d1..3a6cd73aca 100644 --- a/Natives/installer/ForgeInstallViewController.m +++ b/Natives/installer/ForgeInstallViewController.m @@ -40,13 +40,13 @@ - (void)viewDidLoad { }, @"NeoForge": @{ @"installer": @"https://maven.neoforged.net/net/neoforged/forge/%1$@/forge-%1$@-installer.jar", - @"metadata": @"https://maven.neoforged.net/api/maven/versions/releases/net/neoforged/forge" + @"metadata": @"https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml" } }; self.visibilityList = [NSMutableArray new]; self.versionList = [NSMutableArray new]; self.forgeList = [NSMutableArray new]; - [self loadForgeMetadata]; + [self loadMetadataFromVendor:@"Forge"]; } - (void)actionCancelDownload { @@ -57,10 +57,10 @@ - (void)actionClose { [self.navigationController dismissViewControllerAnimated:YES completion:nil]; } -- (void)loadForgeMetadata { +- (void)loadMetadataFromVendor:(NSString *)vendor { [self switchToLoadingState]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSURL *url = [[NSURL alloc] initWithString:self.endpoints[@"Forge"][@"metadata"]]; + NSURL *url = [[NSURL alloc] initWithString:self.endpoints[vendor][@"metadata"]]; NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:url]; parser.delegate = self; if (![parser parse]) { @@ -71,22 +71,6 @@ - (void)loadForgeMetadata { }); } -- (void)loadNeoForgeMetadata { - [self switchToLoadingState]; - AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; - [manager GET:self.endpoints[@"NeoForge"][@"metadata"] parameters:nil headers:nil progress:nil - success:^(NSURLSessionTask *task, NSDictionary *response) { - for (NSString *version in response[@"versions"]) { - [self addVersionToList:version]; - } - [self switchToReadyState]; - [self.tableView reloadData]; - } failure:^(NSURLSessionTask *operation, NSError *error) { - showDialog(localize(@"Error", nil), error.localizedDescription); - [self switchToReadyState]; - }]; -} - - (void)switchToLoadingState { UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleMedium]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:indicator]; @@ -106,14 +90,8 @@ - (void)segmentChanged:(UISegmentedControl *)segment { [self.versionList removeAllObjects]; [self.forgeList removeAllObjects]; [self.tableView reloadData]; - switch (segment.selectedSegmentIndex) { - case 0: - [self loadForgeMetadata]; - break; - case 1: - [self loadNeoForgeMetadata]; - break; - } + NSString *vendor = [segment titleForSegmentAtIndex:segment.selectedSegmentIndex]; + [self loadMetadataFromVendor:vendor]; } #pragma mark UITableViewDataSource @@ -206,6 +184,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } - (void)addVersionToList:(NSString *)version { + if (![version containsString:@"-"]) { + return; + } NSRange range = [version rangeOfString:@"-"]; NSString *gameVersion = [version substringToIndex:range.location]; //NSString *forgeVersion = [version substringFromIndex:range.location + 1];