コード例 #1
0
ファイル: PVELoot.cs プロジェクト: Grimston/PVELoot
        bool CanLootPlayer(BasePlayer target, BasePlayer looter)
        {
            //Check if we have Friends plugin and then if admin or mod
            if (Friends == null || (ServerUsers.Is(looter.userID, ServerUsers.UserGroup.Owner) || ServerUsers.Is(looter.userID, ServerUsers.UserGroup.Moderator)))
            {
                return(true);
            }

            return((bool)Friends.Call("HasFriend", target.userID, looter.userID));
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: evgarik/Oxide.Rust
        /// <summary>
        /// Unbans the player by user ID
        /// </summary>
        public void Unban(ulong id)
        {
            if (!IsBanned(id))
            {
                return;
            }

            ServerUsers.Remove(id);
            ServerUsers.Save();
        }
コード例 #3
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string id, string reason, TimeSpan duration = default(TimeSpan))
        {
            if (IsBanned(id))
            {
                return;
            }

            ServerUsers.Set(ulong.Parse(id), ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
        }
コード例 #4
0
 void LoadBansFile_CMD(ConsoleSystem.Arg arg)
 {
     if (!arg.IsAdmin)
     {
         return;
     }
     LoadingServerUsers = true;
     ServerUsers.Load();
     LoadingServerUsers = false;
     Puts("Loaded Bans From File");
 }
コード例 #5
0
 public void OnNewConnection(Connection connection)
 {
     connection.connected = false;
     if (connection.token == null || (int)connection.token.Length < 32)
     {
         ConnectionAuth.Reject(connection, "Invalid Token");
         return;
     }
     if (connection.userid == 0)
     {
         ConnectionAuth.Reject(connection, "Invalid SteamID");
         return;
     }
     if (connection.protocol != 2177)
     {
         if (!DeveloperList.Contains(connection.userid))
         {
             ConnectionAuth.Reject(connection, "Incompatible Version");
             return;
         }
         DebugEx.Log(string.Concat("Not kicking ", connection.userid, " for incompatible protocol (is a developer)"), StackTraceLogType.None);
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Banned))
     {
         ConnectionAuth.Reject(connection, "You are banned from this server");
         return;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Moderator))
     {
         DebugEx.Log(string.Concat(connection.ToString(), " has auth level 1"), StackTraceLogType.None);
         connection.authLevel = 1;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Owner))
     {
         DebugEx.Log(string.Concat(connection.ToString(), " has auth level 2"), StackTraceLogType.None);
         connection.authLevel = 2;
     }
     if (DeveloperList.Contains(connection.userid))
     {
         DebugEx.Log(string.Concat(connection.ToString(), " is a developer"), StackTraceLogType.None);
         connection.authLevel = 3;
     }
     if (this.IsConnected(connection.userid))
     {
         ConnectionAuth.Reject(connection, "You are already connected!");
         return;
     }
     if (Interface.CallHook("IOnUserApprove", connection) != null)
     {
         return;
     }
     ConnectionAuth.m_AuthConnection.Add(connection);
     base.StartCoroutine(this.AuthorisationRoutine(connection));
 }
コード例 #6
0
ファイル: RustServer.cs プロジェクト: i-love-code/Oxide
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string id, string reason, TimeSpan duration = default(TimeSpan))
        {
            if (IsBanned(id))
            {
                return;
            }

            ServerUsers.Set(ulong.Parse(id), ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
            //if (IsConnected) Kick(reason); // TODO: Implement if possible
        }
コード例 #7
0
ファイル: RustPlayer.cs プロジェクト: Bl4ckSkull666/Oxide
        /// <summary>
        /// Unbans the user
        /// </summary>
        public void Unban()
        {
            // Check not banned
            if (!IsBanned)
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(steamId);
            ServerUsers.Save();
        }
コード例 #8
0
        /// <summary>
        /// Unbans the player
        /// </summary>
        public void Unban(BasePlayer player)
        {
            // Check if unbanned already
            if (!IsBanned(player))
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(player.userID);
            ServerUsers.Save();
        }
コード例 #9
0
ファイル: RustServer.cs プロジェクト: H2oQ13/Oxide
        /// <summary>
        /// Unbans the user
        /// </summary>
        /// <param name="id"></param>
        public void Unban(string id)
        {
            // Check if unbanned already
            if (!IsBanned(id))
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Remove(ulong.Parse(id));
            ServerUsers.Save();
        }
コード例 #10
0
        /// <summary>
        /// Bans the player for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check already banned
            if (IsBanned)
            {
                return;
            }

            // Set to banned
            ServerUsers.Set(steamId, ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
        }
コード例 #11
0
        /// <summary>
        /// Unbans this player
        /// </summary>
        public void Unban()
        {
            // Check not banned
            if (!IsBanned)
            {
                return;
            }

            // Set to unbanned
            ServerUsers.Set(steamid, ServerUsers.UserGroup.None, Nickname, string.Empty);
            ServerUsers.Save();
        }
コード例 #12
0
    public static string BanListStringEx()
    {
        string str = "";
        int    num = 1;

        foreach (ServerUsers.User all in ServerUsers.GetAll(ServerUsers.UserGroup.Banned))
        {
            str = string.Concat(new string[] { str, num.ToString(), " ", all.steamid.ToString(), " ", all.username.QuoteSafe(), " ", all.notes.QuoteSafe(), "\n" });
            num++;
        }
        return(str);
    }
コード例 #13
0
    public static string BanListStringEx()
    {
        IEnumerable <ServerUsers.User> all = ServerUsers.GetAll(ServerUsers.UserGroup.Banned);
        string str = "";
        int    num = 1;

        foreach (ServerUsers.User user in all)
        {
            str = str + num.ToString() + " " + user.steamid.ToString() + " " + StringExtensions.QuoteSafe(user.username) + " " + StringExtensions.QuoteSafe(user.notes) + "\n";
            ++num;
        }
        return(str);
    }
コード例 #14
0
        /// <summary>
        /// Bans this player for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration)
        {
            // Check already banned
            if (IsBanned)
            {
                return;           // TODO: Extend ban duration?
            }
            // Set to banned
            ServerUsers.Set(steamid, ServerUsers.UserGroup.Banned, Nickname, reason);
            ServerUsers.Save();

            // TODO: Set a duration somehow
        }
コード例 #15
0
 public static void Set(ulong uid, ServerUsers.UserGroup group, string username, string notes)
 {
     ServerUsers.Remove(uid);
     ServerUsers.User user = new ServerUsers.User()
     {
         steamid  = uid,
         group    = group,
         username = username,
         notes    = notes
     };
     Interface.CallHook("IOnServerUsersSet", (object)uid, (object)group, (object)username, (object)notes);
     ServerUsers.users.Add(uid, user);
 }
コード例 #16
0
 private void IOnServerUsersRemove(ulong steamId)
 {
     if (serverInitialized)
     {
         string  id      = steamId.ToString();
         IPlayer iplayer = Covalence.PlayerManager.FindPlayerById(id);
         if (ServerUsers.Is(steamId, ServerUsers.UserGroup.Banned))
         {
             Interface.CallHook("OnPlayerUnbanned", iplayer?.Name ?? "Unnamed", steamId, iplayer?.Address ?? "0");
             Interface.CallHook("OnUserUnbanned", iplayer?.Name ?? "Unnamed", id, iplayer?.Address ?? "0");
         }
     }
 }
コード例 #17
0
 public void OnNewConnection(Connection connection)
 {
     connection.connected = false;
     if (connection.token == null || connection.token.Length < 32)
     {
         Reject(connection, "Invalid Token");
         return;
     }
     if (connection.userid == 0L)
     {
         Reject(connection, "Invalid SteamID");
         return;
     }
     if (connection.protocol != 2306)
     {
         if (!DeveloperList.Contains(connection.userid))
         {
             Reject(connection, "Incompatible Version");
             return;
         }
         DebugEx.Log("Not kicking " + connection.userid + " for incompatible protocol (is a developer)");
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Banned))
     {
         ServerUsers.User user  = ServerUsers.Get(connection.userid);
         string           text  = user?.notes ?? "no reason given";
         string           text2 = ((user != null && user.expiry > 0) ? (" for " + (user.expiry - Epoch.Current).FormatSecondsLong()) : "");
         Reject(connection, "You are banned from this server" + text2 + " (" + text + ")");
         return;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Moderator))
     {
         DebugEx.Log(connection.ToString() + " has auth level 1");
         connection.authLevel = 1u;
     }
     if (ServerUsers.Is(connection.userid, ServerUsers.UserGroup.Owner))
     {
         DebugEx.Log(connection.ToString() + " has auth level 2");
         connection.authLevel = 2u;
     }
     if (DeveloperList.Contains(connection.userid))
     {
         DebugEx.Log(connection.ToString() + " is a developer");
         connection.authLevel = 3u;
     }
     if (Interface.CallHook("IOnUserApprove", connection) == null)
     {
         m_AuthConnection.Add(connection);
         StartCoroutine(AuthorisationRoutine(connection));
     }
 }
コード例 #18
0
ファイル: Player.cs プロジェクト: Skippeh/Oxide
        /// <summary>
        /// Bans the player from the server
        /// </summary>
        /// <param name="player"></param>
        /// <param name="reason"></param>
        public void Ban(BasePlayer player, string reason = "")
        {
            if (IsBanned(player))
            {
                return;
            }

            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, reason);
            ServerUsers.Save();
            if (IsConnected(player))
            {
                Kick(player, reason);
            }
        }
コード例 #19
0
 void ClearLocalBans(ConsoleSystem.Arg arg)
 {
     if (!arg.IsAdmin)
     {
         return;
     }
     LoadingServerUsers = true;
     foreach (var ban in ServerUsers.GetAll(ServerUsers.UserGroup.Banned).ToList())
     {
         ServerUsers.Remove(ban.steamid);
     }
     LoadingServerUsers = false;
     Puts($"Cleared Server Bans");
 }
コード例 #20
0
        private IEnumerator SaveBansToDatabase()
        {
            var bans = ServerUsers.GetAll(ServerUsers.UserGroup.Banned).ToList();

            yield return(null); //Gotta have that debug message show when you first load the plguin

            Puts($"Starting To Push {bans.Count} Bans To Database");
            foreach (var user in bans)
            {
                UpdateUserGroup(user.steamid, user.group, user.username, user.notes);
                yield return(null);
            }
            Puts("Finished Saving All Bans To The Database");
            yield return(null);
        }
コード例 #21
0
    private bool CanJumpQueue(Connection connection)
    {
        object obj = Interface.CallHook("CanBypassQueue", (object)connection);

        if (obj is bool)
        {
            return((bool)obj);
        }
        if (DeveloperList.Contains((ulong)connection.userid))
        {
            return(true);
        }
        ServerUsers.User user = ServerUsers.Get((ulong)connection.userid);
        return(user != null && user.group == ServerUsers.UserGroup.Moderator || user != null && user.group == ServerUsers.UserGroup.Owner);
    }
コード例 #22
0
ファイル: AdminToggle.cs プロジェクト: rustmy/oxideplugins-1
        void ToggleAdmin(BasePlayer player)
        {
            if (!CheckPermission(player))
            {
                return;
            }

            if (!data.AdminData.ContainsKey(player.userID.ToString()))
            {
                data.AdminData.Add(player.userID.ToString(), new AdminData(player));
            }

            if (data.AdminData[player.userID.ToString()].PlayerName == "")
            {
                SendChatMessage(player, "AdminToggle", "You did not set up your player name yet. Set it up using /setplayername");
                return;
            }

            displayname.SetValue(player, data.AdminData[player.userID.ToString()].EnabledPlayerMode ? data.AdminData[player.userID.ToString()].AdminName : data.AdminData[player.userID.ToString()].PlayerName);

            if (data.AdminData[player.userID.ToString()].EnabledPlayerMode)
            {
                ServerUsers.Set(player.userID, ServerUsers.UserGroup.Owner, player.displayName, "");
                ConVar.Server.writecfg(new ConsoleSystem.Arg(""));

                permission.AddUserGroup(player.userID.ToString(), Config["Groups", "Admin Group"].ToString());
                permission.RemoveUserGroup(player.userID.ToString(), Config["Groups", "Player Group"].ToString());

                SendChatMessage(player, "AdminToggle", "You switched to admin mode!");
            }
            else
            {
                ServerUsers.Set(player.userID, ServerUsers.UserGroup.None, player.displayName, "");
                ConVar.Server.writecfg(new ConsoleSystem.Arg(""));

                permission.AddUserGroup(player.userID.ToString(), Config["Groups", "Player Group"].ToString());
                permission.RemoveUserGroup(player.userID.ToString(), Config["Groups", "Admin Group"].ToString());


                SendChatMessage(player, "AdminToggle", "You switched to player mode!");
            }

            data.AdminData[player.userID.ToString()].EnabledPlayerMode = !data.AdminData[player.userID.ToString()].EnabledPlayerMode;
            SaveData();

            SendChatMessage(player, "AdminToggle", "You will be kicked in 5 seconds to update your status. Please reconnect!");
            timer.Once(5, () => player.SendConsoleCommand("client.disconnect"));
        }
コード例 #23
0
ファイル: Player.cs プロジェクト: PJFruhling/Oxide.Rust
        /// <summary>
        /// Bans the player from the server based on user ID
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        public void Ban(ulong id, string reason = "")
        {
            if (IsBanned(id))
            {
                return;
            }

            var player = FindById(id);

            ServerUsers.Set(id, ServerUsers.UserGroup.Banned, player?.displayName ?? "Unknown", reason);
            ServerUsers.Save();
            if (player != null && IsConnected(player))
            {
                Kick(player, reason);
            }
        }
コード例 #24
0
        /// <summary>
        /// Bans the player from the server
        /// </summary>
        /// <param name="player"></param>
        /// <param name="reason"></param>
        public void Ban(BasePlayer player, string reason = "")
        {
            // Check if already banned
            if (IsBanned(player))
            {
                return;
            }

            // Ban and kick user
            ServerUsers.Set(player.userID, ServerUsers.UserGroup.Banned, player.displayName, reason);
            ServerUsers.Save();
            if (IsConnected(player))
            {
                Kick(player, reason);
            }
        }
コード例 #25
0
ファイル: RustPlayer.cs プロジェクト: Bl4ckSkull666/Oxide
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check if already banned
            if (IsBanned)
            {
                return;
            }

            // Ban and kick user
            ServerUsers.Set(steamId, ServerUsers.UserGroup.Banned, Name, reason);
            ServerUsers.Save();
            if (IsConnected)
            {
                Kick(reason);
            }
        }
コード例 #26
0
 //Hook Load (Load from DB instead of File)
 void OnServerLoadUsers()
 {
     //NOW DO YOUR LOAD STUFF HERE
     LoadingServerUsers = true;
     foreach (var row in banDB.Query($"SELECT * FROM {TableName}"))
     {
         //https://stackoverflow.com/questions/11226448/invalidcastexception-long-to-ulong
         //Never knew you had to cast to long then ulong in a specific situation
         ulong steamID = (ulong)((long)row.Value["steamid"]);
         ServerUsers.UserGroup group = (ServerUsers.UserGroup)row.Value.GetInt("usergroup");
         string name   = row.Value.GetString("username") ?? "";
         string reason = row.Value.GetString("notes") ?? "";
         ServerUsers.Set(steamID, group, name, reason);
     }
     LoadingServerUsers = false;
 }
コード例 #27
0
        private void cmdChatDroplimit(BasePlayer player, string command, string[] args)
        {
            var usage = _("Usage: /droplimit \"ITEMNAME\" [LIMIT]");

            if (!initialized)
            {
                return;
            }
            if (!ServerUsers.Is(player.userID, ServerUsers.UserGroup.Owner))
            {
                SendReply(player, _("You are not authorized to modify drop limits"));
                return;
            }
            if (args.Length < 1)
            {
                SendReply(player, usage);
                return;
            }
            string name = args[0];
            int    currentLimit;

            if (!dropLimits.TryGetValue(name, out currentLimit))
            {
                SendReply(player, _("No such item:") + " " + name);
                return;
            }
            if (args.Length == 1)
            {
                SendReply(player, _("Drop limit of '%NAME%' is %LIMIT%", new Dictionary <string, string>()
                {
                    { "ITEM", name },
                    { "LIMIT", currentLimit.ToString() }
                }));
                return;
            }
            int limit = Convert.ToInt32(args[1]);

            dropLimits[name] = limit;
            SaveConfig();
            SendReply(player, "Drop limit of '%NAME%' has been changed from %LIMIT% to %NEWLIMIT%", new Dictionary <string, string>()
            {
                { "NAME", name },
                { "LIMIT", currentLimit.ToString() },
                { "NEWLIMIT", limit.ToString() }
            });
        }
コード例 #28
0
        public static void unban(ConsoleSystem.Arg arg)
        {
            ulong num = arg.GetUInt64(0, (ulong)0);

            if (num < 70000000000000000L)
            {
                arg.ReplyWith(string.Concat("This doesn't appear to be a 64bit steamid: ", num));
                return;
            }
            ServerUsers.User user = ServerUsers.Get(num);
            if (user == null || user.@group != ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith(string.Concat("User ", num, " isn't banned"));
                return;
            }
            ServerUsers.Remove(num);
            arg.ReplyWith(string.Concat("Unbanned User: ", num));
        }
コード例 #29
0
ファイル: Admin.cs プロジェクト: Ailtop/RustDocuments
        public static void removeowner(Arg arg)
        {
            ulong uInt = arg.GetUInt64(0, 0uL);

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith("This doesn't appear to be a 64bit steamid: " + uInt);
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user == null || user.group != ServerUsers.UserGroup.Owner)
            {
                arg.ReplyWith("User " + uInt + " isn't an owner");
                return;
            }
            ServerUsers.Remove(uInt);
            arg.ReplyWith("Removed Owner: " + uInt);
        }
コード例 #30
0
ファイル: Admin.cs プロジェクト: Ailtop/RustDocuments
        public static void unban(Arg arg)
        {
            ulong uInt = arg.GetUInt64(0, 0uL);

            if (uInt < 70000000000000000L)
            {
                arg.ReplyWith($"This doesn't appear to be a 64bit steamid: {uInt}");
                return;
            }
            ServerUsers.User user = ServerUsers.Get(uInt);
            if (user == null || user.group != ServerUsers.UserGroup.Banned)
            {
                arg.ReplyWith($"User {uInt} isn't banned");
                return;
            }
            ServerUsers.Remove(uInt);
            arg.ReplyWith("Unbanned User: " + uInt);
        }