Exemplo n.º 1
0
        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("-", "_"));
                }
            }
        }