/// <summary> /// Creates Builds /// </summary> public static void CreateDefualtBuild() { try { var filename = $"{BuildName()}.json"; var buildUrl = $"https://raw.githubusercontent.com/plsfixrito/AramBuddy.Data/master/Default/{filename}"; var result = Weeb.ReadString(buildUrl).Result; if (string.IsNullOrEmpty(result)) { Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("No Build is being used !", Logger.LogLevel.Warn); return; } if (result.Contains("data")) { File.WriteAllText(Setup.BuildPath + "\\" + filename, result); Setup.Builds.Add(BuildName(), File.ReadAllText(Setup.BuildPath + "\\" + filename)); Logger.Send(BuildName() + " Build Created for " + Player.Instance.ChampionName + " - " + BuildName()); Setup.UseDefaultBuild(); } else { Logger.Send("Wrong Response, No Champion Build Created", Logger.LogLevel.Warn); Console.WriteLine(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 GetBuildFromService() { try { var filename = $"{Player.Instance.CleanChampionName()}.json"; var buildUrl = $"https://raw.githubusercontent.com/plsfixrito/AramBuddy.Data/master/{Config.CurrentPatchUsed}/ItemBuilds/{filename}"; var result = Weeb.ReadString(buildUrl).Result; if (string.IsNullOrEmpty(result)) { Logger.Send("Wrong Response or was canceled, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); return; } if (result.Contains("data")) { var filepath = $"{Setup.BuildPath}/{filename}"; File.WriteAllText(filepath, result); Setup.Builds.Add(Player.Instance.CleanChampionName(), File.ReadAllText(filepath)); Logger.Send("Created Build for " + Player.Instance.ChampionName); Setup.CustomBuildService(); } else { Logger.Send("Wrong Response, No Champion Build Created !", Logger.LogLevel.Warn); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); } } catch (Exception ex) { // if faild to create build terminate the AutoShop Logger.Send($"Failed to create Build from service {Config.CurrentPatchUsed} for {Player.Instance.ChampionName}", Logger.LogLevel.Error); Logger.Send(ex.InnerException?.Message, Logger.LogLevel.Error); Logger.Send("Trying To Get Defualt Build !", Logger.LogLevel.Warn); Setup.UseDefaultBuild(); } }
private static void DownLoadLevelSet() { try { var result = Weeb.ReadString(FileURL).Result; if (!string.IsNullOrEmpty(result) && result.Contains("LevelSet")) { File.WriteAllText(LevelSetFile, result); TryParseData(result, out CurrentLevelset); Logger.Send($"Created LevelSet For {Player.Instance.ChampionName}"); } else { Logger.Send("Failed to create Levelset.", Logger.LogLevel.Warn); Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); } } catch (Exception ex) { Logger.Send("ERROR: ", ex, Logger.LogLevel.Error); } }
public static void Init() { try { Logger.Send("Checking For Updates.."); var size = Drawing.Width <= 1280 || Drawing.Height <= 720 ? 10F : 40F; text = new Text("ARAMBUDDY OUTDATED! PLEASE UPDATE!", new Font("Euphemia", size, FontStyle.Bold)) { Color = Color.White }; UpdateMsg = Weeb.ReadString(UpdateMsgPath).Result; if (string.IsNullOrEmpty(UpdateMsg)) { UpdateMsg = "Failed to get update msg."; } var onlineVersion = Weeb.ReadString(WebVersionPath).Result; if (string.IsNullOrEmpty(onlineVersion)) { Logger.Send("Failed to check for updates.", Logger.LogLevel.Warn); } else { if (!onlineVersion.Contains(CurrentVersion.ToString())) { Drawing.OnEndScene += delegate { text.Position = new Vector2(Drawing.Width * 0.01f, Drawing.Height * 0.1f); text.Draw(); }; Outdated = true; Logger.Send("Update available for AramBuddy!", Logger.LogLevel.Warn); Logger.Send("Update Log: " + UpdateMsg); Game.OnTick += delegate { if (UpdateMsg != string.Empty && !Sent && Outdated) { Chat.Print("<b>AramBuddy: Update available for AramBuddy!</b>"); Chat.Print("<b>AramBuddy Update Log: " + UpdateMsg + "</b>"); Notifications.Show(new SimpleNotification("ARAMBUDDY OUTDATED", "Update Log: " + UpdateMsg), 25000); Sent = true; } }; } else { Logger.Send("AramBuddy is updated to the latest version!"); } } /*var WebClient = new WebClient(); * WebClient.DownloadStringTaskAsync(UpdateMsgPath); * WebClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args) * { * if (args.Cancelled || args.Error != null) * { * Logger.Send("Failed to get update Message.", Logger.LogLevel.Warn); * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * return; * } * * UpdateMsg = args.Result; * * WebClient.Dispose(); * };*/ /* * var WebClient2 = new WebClient(); * WebClient2.DownloadStringTaskAsync(WebVersionPath); * WebClient2.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs args) * { * if (args.Cancelled || args.Error != null) * { * Logger.Send("Failed to check live version.", Logger.LogLevel.Warn); * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * return; * } * if (args.Cancelled) * { * Logger.Send("Wrong response, or request was cancelled.", Logger.LogLevel.Warn); * Logger.Send(args.Error?.InnerException?.Message, Logger.LogLevel.Warn); * Console.WriteLine(args.Result); * } * if (!args.Result.Contains(CurrentVersion.ToString())) * { * Drawing.OnEndScene += delegate * { * text.Position = new Vector2(Drawing.Width * 0.01f, Drawing.Height * 0.1f); * text.Draw(); * }; * Outdated = true; * Logger.Send("Update available for AramBuddy!", Logger.LogLevel.Warn); * Logger.Send("Update Log: " + UpdateMsg); * } * else * { * Logger.Send("AramBuddy is updated to the latest version!"); * } * WebClient2.Dispose(); * }; * * Game.OnTick += delegate * { * if (UpdateMsg != string.Empty && !Sent && Outdated) * { * Chat.Print("<b>AramBuddy: Update available for AramBuddy!</b>"); * Chat.Print("<b>AramBuddy Update Log: " + UpdateMsg + "</b>"); * Notifications.Show(new SimpleNotification("ARAMBUDDY OUTDATED", "Update Log: " + UpdateMsg), 25000); * Sent = true; * } * };*/ } catch (Exception ex) { Logger.Send("Update check failed!", ex, Logger.LogLevel.Error); } }