internal void FirstSteamGroups() { // Create the array SteamGroupConfig.Document.Add("SteamGroups", new JArray()); // Ceate the groups SteamGroup group = new SteamGroup(103582791437463178, -1, false, false); // Configure steam group group.AddPermission("unturned.commands.noadmin.*"); group.AddPrefix("Workshopper"); group.AddSuffix("Workshopper"); SteamGroupManager.AddSteamGroup(group); // Save the groups SaveSteamGroups(); }
internal void LoadSteamGroups() { foreach (JObject obj in (JArray)SteamGroupConfig.Document["SteamGroups"]) { if (SteamGroupManager.Groups.Count(a => a.ID == (ulong)obj["Steam64"]) > 0) { continue; } SteamGroup g = new SteamGroup((ulong)obj["Steam64"], (int)obj["Cooldown"], false, false); SteamGroupManager.AddSteamGroup(g); } foreach (SteamGroup g in SteamGroupManager.Groups) { JObject obj = SteamGroupConfig.Document["SteamGroups"].FirstOrDefault(a => (ulong)a["Steam64"] == g.ID) as JObject; if (obj["Inherits"] is JArray) { foreach (JToken token in (JArray)obj["Inherits"]) { if (string.IsNullOrEmpty((string)token)) { continue; } SteamGroup i = SteamGroupManager.Groups.FirstOrDefault(a => a.ID == ulong.Parse((string)token)); if (i == null || g.Inherits.Contains(i) || g == i) { continue; } g.AddInherit(i); } } else { if (string.IsNullOrEmpty((string)obj["Inherits"])) { continue; } SteamGroup i = SteamGroupManager.Groups.FirstOrDefault(a => a.ID == ulong.Parse((string)obj["Inherits"])); if (i == null || g.Inherits.Contains(i) || g == i) { continue; } g.AddInherit(i); } if (obj["Permissions"] is JArray) { foreach (JToken token in (JArray)obj["Permissions"]) { if (g.Permissions.Contains((string)token)) { continue; } g.AddPermission((string)token); } } else { if (g.Permissions.Contains((string)obj["Permissions"])) { continue; } g.AddPermission((string)obj["Permissions"]); } if (obj["Prefixes"] is JArray) { foreach (JToken token in (JArray)obj["Prefixes"]) { if (g.Prefixes.Contains((string)token)) { continue; } g.AddPrefix((string)token); } } else { if (g.Prefixes.Contains((string)obj["Prefixes"])) { continue; } g.AddPrefix((string)obj["Prefixes"]); } if (obj["Suffixes"] is JArray) { foreach (JToken token in (JArray)obj["Suffixes"]) { if (g.Suffixes.Contains((string)token)) { continue; } g.AddSuffix((string)token); } } else { if (g.Suffixes.Contains((string)obj["Suffixes"])) { continue; } g.AddSuffix((string)obj["Suffixes"]); } } }