/// <summary> /// Creates Builds /// </summary> public static void Create() { try { var filename = BuildName() + ".json"; var WebClient = new WebClient(); WebClient.DownloadStringTaskAsync("https://raw.githubusercontent.com/plsfixrito/AramBuddy/master/DefaultBuilds/" + filename); WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args) { if (args.Result.Contains("data")) { File.WriteAllText(Setup.BuildPath + "\\" + filename, args.Result); Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename)); Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName(), Logger.LogLevel.Info); Setup.DefaultBuild(); } else { Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn); Console.WriteLine(args.Result); } }; } catch (Exception ex) { // if faild to create build terminate the AutoShop Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error); Logger.Send("No build is currently being used!", Logger.LogLevel.Error); } }
/// <summary> /// Creates Builds /// </summary> public static void CreateDefualtBuild() { try { var filename = BuildName() + ".json"; using (var WebClient = new WebClient()) { using (var request = WebClient.DownloadStringTaskAsync("https://raw.githubusercontent.com/r3d4ilx3cdfxd/AramBuddy/master/DefaultBuilds/" + filename)) { if (request.IsFaulted || request.IsCanceled) { Logger.Send("Wrong Response, Or Request Was Cancelled", Logger.LogLevel.Warn); Logger.Send(request?.Exception?.InnerException?.Message, Logger.LogLevel.Warn); Console.WriteLine(request.Result); } else { if (request.Result != null && request.Result.Contains("data")) { File.WriteAllText(Setup.BuildPath + "\\" + filename, request.Result); Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename)); Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName()); Setup.DefaultBuild(); } else { Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn); Console.WriteLine(request.Result); } } } } } catch (Exception ex) { // if faild to create build terminate the AutoShop Logger.Send("Failed to create default build for " + Player.Instance.ChampionName, ex, Logger.LogLevel.Error); Logger.Send("No build is currently being used!", Logger.LogLevel.Error); } }