private static async Task LoadPlayerName(string search, bool forceResolution, List <PlayerResult> result) { var client = new RestClient("https://mc-heads.net/"); var request = new RestRequest($"/minecraft/profile/{search}", Method.GET); var response = await client.ExecuteAsync(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { if (forceResolution) { throw new CoflnetException("player_not_found", $"we don't know of a player with the name {search}"); } else { // nothing to do } } else { var value = JsonConvert.DeserializeObject <SearchCommand.MinecraftProfile>(response.Content); NameUpdater.UpdateUUid(value.Id, value.Name); result.Add(new PlayerResult(value.Name, value.Id)); } }
private static void FullServer() { Console.WriteLine($"\n - Starting FullServer {version} - \n"); Console.Write("Key: " + apiKey); FullServerMode = true; Indexer.MiniumOutput(); server = new Server(); Task.Run(() => server.Start()).ConfigureAwait(false); Task.Run(() => CreateHost(new string[0])).ConfigureAwait(false); var mode = SimplerConfig.Config.Instance["MODE"]; LightClient = mode == "light"; if (LightClient) { ItemDetails.Instance.LoadLookup(); RunIsolatedForever(async() => { await Task.Delay(TimeSpan.FromMinutes(1)); await SearchService.Instance.SaveHits(); }, "saving hits failed"); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); } updater = new Updater(apiKey); updater.UpdateForEver(); // bring the db up to date GetDBToDesiredState(); ItemDetails.Instance.LoadFromDB(); SubscribeEngine.Instance.LoadFromDb(); var redisInit = MakeSureRedisIsInitialized(); Console.WriteLine("booting db dependend stuff"); var bazzar = new BazaarUpdater(); bazzar.UpdateForEver(apiKey); RunIndexer(); Flipper.FlipperEngine.diabled = FileController.Exists("blockFlipper"); for (int i = 0; i < 4; i++) { RunIsolatedForever(Flipper.FlipperEngine.Instance.ProcessPotentialFlipps, $"flipper worker {i} got error"); } NameUpdater.Run(); SearchService.Instance.RunForEver(); CacheService.Instance.RunForEver(); Task.Run(async() => { await Task.Delay(TimeSpan.FromMinutes(3)); await ItemPrices.Instance.BackfillPrices(); }).ConfigureAwait(false);; onStop += () => { StopServices(updater, server, bazzar); }; try { CleanDB(); } catch (Exception e) { Console.WriteLine($"Cleaning failed {e.Message}"); } redisInit.GetAwaiter().GetResult(); System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite); }