public static List <BukgetPlugin> ParsePluginList(string json) { List <BukgetPlugin> result = new List <BukgetPlugin>(); if (json.StartsWith("[")) { JsonArray jsonArray = JsonConvert.Import <JsonArray>(json); foreach (JsonObject jsonObject in jsonArray) { BukgetPlugin plugin = new BukgetPlugin(jsonObject.ToString()); if (string.IsNullOrEmpty(plugin.Main) || string.IsNullOrEmpty(plugin.Name)) { continue; } result.Add(plugin); } } else { result.Add(new BukgetPlugin(json)); } return(result); }
/// <summary> /// Retrieve a list of plugins, parse it, store it in the currentlyLoadedPlugins variable and return it /// </summary> /// <param name="url"></param> /// <returns></returns> private static Dictionary <String, BukgetPlugin> RetrieveParseStore(String url) { string data = WebUtil.RetrieveString(url); CurrentlyLoadedPlugins = ListToDictionary(BukgetPlugin.ParsePluginList(data)); RaiseNewPluginsLoaded(); return(CurrentlyLoadedPlugins); }
public BukgetPluginVersion(BukgetPlugin plugin, String jsonCode) { { InitFields(); //create JSON object JsonObject json = (JsonObject) JsonConvert.Import(jsonCode); Plugin = plugin; if (json["version"] == null) { VersionNumber = null; return; } VersionNumber = json["version"].ToString(); { CompatibleBuilds = JsonParser.ParseJsonStringList( json["game_versions"]); } if (json["download"] != null) { // BukkitDev Compliancy // Since this program is distributed using dev.bukkit.org, every download url needs to have the "http://dev.bukkit.org" part hardcoded DownloadLink = json["download"].ToString(); if (DownloadLink.StartsWith("http://") || DownloadLink.StartsWith("https://")) { DownloadLink = DownloadLink.Substring(DownloadLink.IndexOf('/', 10)); DownloadLink = "http://dev.bukkit.org/" + DownloadLink; } } if (json["link"] != null) PageLink = json["link"].ToString(); if (json["date"] != null) ReleaseDate = new DateTime(1970, 1, 1).AddSeconds(Convert.ToDouble(json["date"].ToString())); if (json["filename"] != null) Filename = json["filename"].ToString(); if (json["status"] != null) Type = (PluginStatus) Enum.Parse(typeof (PluginStatus), json["status"].ToString().Replace("-", "_")); } }
private void LoadPlugin(BukgetPlugin plugin) { string detail = Locale.Tr("Name:") + " " + plugin.Name + Environment.NewLine + Environment.NewLine + Locale.Tr("Author(s):") + " " + StringUtil.ListToCsv(plugin.AuthorsList) + Environment.NewLine + Environment.NewLine + Locale.Tr("Description:") + " " + plugin.Description + Environment.NewLine + Environment.NewLine + Locale.Tr("Categories:") + " " + StringUtil.ListToCsv(plugin.CategoryList) + Environment.NewLine + Environment.NewLine + Locale.Tr("Main namespace:") + " " + plugin.Main + Environment.NewLine + Environment.NewLine + Locale.Tr("Status:") + " " + plugin.Status + Environment.NewLine + Environment.NewLine + Locale.Tr("Website:") + " " + plugin.Website; lblPluginDetail.Text = detail; LoadVersions(plugin.VersionsList); }
public static List<BukgetPlugin> ParsePluginList(string json) { List<BukgetPlugin> result = new List<BukgetPlugin>(); if (json.StartsWith("[")) { JsonArray jsonArray = JsonConvert.Import<JsonArray>(json); foreach (JsonObject jsonObject in jsonArray) { BukgetPlugin plugin = new BukgetPlugin(jsonObject.ToString()); if (string.IsNullOrEmpty(plugin.Main) || string.IsNullOrEmpty(plugin.Name)) continue; result.Add(plugin); } } else { result.Add(new BukgetPlugin(json)); } return result; }
public BukgetPluginVersion(BukgetPlugin plugin, String jsonCode) { { InitFields(); //create JSON object JsonObject json = (JsonObject)JsonConvert.Import(jsonCode); Plugin = plugin; if (json["version"] == null) { VersionNumber = null; return; } VersionNumber = json["version"].ToString(); { CompatibleBuilds = JsonParser.ParseJsonStringList( json["game_versions"]); } if (json["download"] != null) { // BukkitDev Compliancy // Since this program is distributed using dev.bukkit.org, every download url needs to have the "http://dev.bukkit.org" part hardcoded DownloadLink = json["download"].ToString(); if (DownloadLink.StartsWith("http://") || DownloadLink.StartsWith("https://")) { DownloadLink = DownloadLink.Substring(DownloadLink.IndexOf('/', 10)); DownloadLink = "http://dev.bukkit.org/" + DownloadLink; } } if (json["link"] != null) { PageLink = json["link"].ToString(); } if (json["date"] != null) { ReleaseDate = new DateTime(1970, 1, 1).AddSeconds(Convert.ToDouble(json["date"].ToString())); } if (json["filename"] != null) { Filename = json["filename"].ToString(); } if (json["status"] != null) { Type = (PluginStatus)Enum.Parse(typeof(PluginStatus), json["status"].ToString().Replace("-", "_")); } } }