public override void Load() { Harmony.PatchAll(); ConfirmExtraRoles.Group = ER_GROUP; ShowExtraRoles.Group = ER_GROUP; LanguageManager.Load(Assembly.GetExecutingAssembly(), "ExtraRoles.Lang."); Role.Load(); VersionsList.Add("ExtraRoles", Version, true); CommandsController.Register(new WinCommand()); HandleRpcPatch.AddListener(new RPCExtraRoles()); EventsController.RESET_ALL.Register(() => { Role.ResetAll(); KilledPlayers.Clear(); }); }
/// <summary> /// Parse a bukget plugin from the json result /// </summary> /// <param name="jsonCode"></param> /// <returns></returns> public BukgetPlugin(string jsonCode) { InitFields(); if (string.IsNullOrEmpty(jsonCode)) { throw new FormatException("Invalid JSON supplied: string is empty"); } if (Equals(jsonCode, "[]")) { throw new FormatException("Invalid JSON supplied: array is empty"); } // Load the string into a json object JsonObject json; // In case of an array, load the first entry try { if (jsonCode.StartsWith("[")) { json = (JsonObject)JsonConvert.Import <JsonArray>(jsonCode)[0]; } else { json = JsonConvert.Import <JsonObject>(jsonCode); } } catch (Exception exception) { throw new FormatException("Invalid JSON supplied: " + exception); } if (json["main"] != null) { Main = (string)json["main"]; } if (json["plugin_name"] != null) { Name = (string)json["plugin_name"]; } // If no name or mainspace, return if (string.IsNullOrEmpty(Main) || string.IsNullOrEmpty(Name)) { return; } Logger.Log(LogLevel.Info, "BukGetAPI", "parsing plugin:" + Name, Main); // Slug if (json["slug"] != null) { Slug = (String)json["slug"]; } // Description if (json["description"] != null) { Description = (String)json["description"]; } // BukkitDev link if (json["dbo_page"] != null) { BukkitDevLink = (String)json["dbo_page"]; } // Website if (json["link"] != null) { Website = (String)json["link"]; } // Stage if (json["stage"] != null) { try { Status = (PluginStatus)Enum.Parse(typeof(PluginStatus), json["stage"].ToString()); } catch (Exception e) { Logger.Log(LogLevel.Warning, "BukgetV3", "Couldn't parse plugin status", e.Message); } } // Authors AuthorsList = JsonParser.ParseJsonStringList(json["authors"]); // Categories // load strings List <String> categories = JsonParser.ParseJsonStringList(json["categories"]); // convert to enum values foreach (string category in categories) { CategoryList.Add((PluginCategory)Enum.Parse(typeof(PluginCategory), category)); } // Versions IEnumerable <JsonObject> versions = JsonParser.ParseJsonObjectList(json["versions"]); foreach (JsonObject jsonObject in versions) { BukgetPluginVersion v = new BukgetPluginVersion(this, jsonObject.ToString()); if (v.VersionNumber != null) { VersionsList.Add(v); } } LastParsedPlugin = this; }