Exemplo n.º 1
0
        /// <summary>
        /// Tries to find the steam group by ID and returns it
        /// </summary>
        /// <param name="ID">The steam64 of the steam group</param>
        /// <param name="group">The returned instace of the found steam group</param>
        /// <returns>Has the group been found</returns>
        public static bool TryFindSteamGroup(ulong ID, out SteamGroup group)
        {
            SteamGroup g = Find(ID);

            group = g;
            return(g != null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes an inherit from the steam group
        /// </summary>
        /// <param name="group">The inherit to remove</param>
        public void RemoveInherit(SteamGroup group)
        {
            if (!_Inherits.Contains(group))
            {
                return;
            }

            _Inherits.Remove(group);
            SteamGroupEvents.RunInheritRemoved(this, group);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Removes a steam group from the server
        /// </summary>
        /// <param name="group">The group to remove</param>
        public static void RemoveSteamGroup(SteamGroup group)
        {
            if (!_Groups.ContainsValue(group))
            {
                return;
            }
            _Groups.Remove(group.ID);

            SteamGroupEvents.RunSteamGroupRemoved(group);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds a steam group to the server
        /// </summary>
        /// <param name="group">The steam group to add</param>
        public static void AddSteamGroup(SteamGroup group)
        {
            if (_Groups.ContainsKey(group.ID))
            {
                return;
            }
            _Groups.Add(group.ID, group);

            SteamGroupEvents.RunSteamGroupAdded(group);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Removes a steam group from the server
        /// </summary>
        /// <param name="ID">The steam group ID to remove</param>
        public static void RemoveSteamGroup(ulong ID)
        {
            if (_Groups.ContainsKey(ID))
            {
                return;
            }
            SteamGroup group = _Groups[ID];

            _Groups.Remove(ID);

            SteamGroupEvents.RunSteamGroupRemoved(group);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates and adds a steam group to the server
        /// </summary>
        /// <param name="ID">The ID of the steam group</param>
        /// <param name="cooldown">The command cooldown of the steam group</param>
        public static void AddSteamGroup(ulong ID, int cooldown)
        {
            if (_Groups.ContainsKey(ID))
            {
                return;
            }
            SteamGroup group = new SteamGroup(ID, cooldown);

            _Groups.Add(ID, group);

            SteamGroupEvents.RunSteamGroupAdded(group);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds an inherit to the steam group
        /// </summary>
        /// <param name="group">The group to add to inherits</param>
        public void AddInherit(SteamGroup group)
        {
            if (_Inherits.Contains(group))
            {
                return;
            }
            if (_Inherits.Count(a => a.ID == group.ID) > 0)
            {
                return;
            }

            _Inherits.Add(group);
            SteamGroupEvents.RunInheritAdded(this, group);
        }
Exemplo n.º 8
0
        /// <summary>
        /// The player information on steam
        /// </summary>
        /// <param name="id">The Steam64 of the player</param>
        public SteamPlayer(ulong id)
        {
            // Set the variables
            this.ID = id;

            // Setup the XML
            try
            {
                XmlDocument document = new XmlDocument();
                document.Load($"http://steamcommunity.com/profiles/{ID.ToString()}/?xml=1");
                XmlNode root = document.DocumentElement;

                // Set the data
                if (root != null)
                {
                    Name          = root.SelectSingleNode("steamID").InnerText.Replace("<![CDATA[ ", "").Replace(" ]]>", "");
                    IsVisible     = (int.Parse(root.SelectSingleNode("visibilityState").InnerText) > 0);
                    IsVACBanned   = (int.Parse(root.SelectSingleNode("vacBanned").InnerText) > 0);
                    IsTradeBanned = (root.SelectSingleNode("tradeBanState").InnerText != "None");
                    IsLimited     = (int.Parse(root.SelectSingleNode("isLimitedAccount").InnerText) > 0);

                    string privacystate = root.SelectSingleNode("privacyState").InnerText;
                    switch (privacystate)
                    {
                    case "public":
                        PrivacyState = EPrivacyState.PUBLIC;
                        break;

                    case "friendsonly":
                        PrivacyState = EPrivacyState.FRIENDS_ONLY;
                        break;

                    case "private":
                        PrivacyState = EPrivacyState.PRIVATE;
                        break;

                    default:
                        PrivacyState = EPrivacyState.NONE;
                        break;
                    }

                    if (PrivacyState == EPrivacyState.PUBLIC)
                    {
                        List <SteamGroup> groups = new List <SteamGroup>();
                        foreach (XmlNode node in root.SelectNodes("groups/group"))
                        {
                            ulong      i     = ulong.Parse(node.SelectSingleNode("groupID64").InnerText);
                            SteamGroup group = SteamGroupManager.Groups.FirstOrDefault(a => a.ID == i);

                            if (group == null)
                            {
                                group = new SteamGroup(i, -1, false, true);
                                SteamGroupManager.AddSteamGroup(group);
                            }
                            groups.Add(group);
                        }
                        Groups = groups.ToArray();
                    }
                    else
                    {
                        Groups = new SteamGroup[0];
                    }
                }
                else
                {
                    Name          = "";
                    Groups        = new SteamGroup[0];
                    PrivacyState  = EPrivacyState.NONE;
                    IsVisible     = false;
                    IsVACBanned   = false;
                    IsTradeBanned = false;
                    IsLimited     = false;
                }
            }
            catch (Exception ex)
            {
                Logging.LogError("Issue occured when getting info for " + ID, ex);
            }
        }