public async Task <bool> BanAsync(IUser user, IUser bannedBy = null, string reason = null, TimeSpan?duration = null)
        {
            UserBanEvent @event = new UserBanEvent(user, bannedBy, reason, duration, true);

            eventManager.Emit(host, @event);
            if (@event.IsCancelled)
            {
                return(false);
            }

            var callerId = (bannedBy is UnturnedUser up) ? up.CSteamID : CSteamID.Nil;

            //if (user.IsOnline)
            //{
            //    SteamBlacklist.ban(player.CSteamID, 0, callerId, reason, (uint)(duration?.TotalSeconds ?? uint.MaxValue));
            //    return true;
            //}

            var steamId = new CSteamID(ulong.Parse(user.Id));

            SteamBlacklist.ban(steamId, 0, callerId, reason, (uint)(duration?.TotalSeconds ?? uint.MaxValue));

            var target = ((UnturnedUser)user).Player;

            if (target.IsOnline)
            {
                Provider.kick(steamId, reason);
            }

            return(true);
        }
        private void OnPlayerDisconnected(UnturnedPlayer player)
        {
            int  playerPoints;
            bool playerExists = dicPoints.TryGetValue(player.CSteamID, out playerPoints);

            if (playerExists)
            {
                dicPoints.Remove(player.CSteamID);
            }

            if (Instance.Configuration.Instance.LogIDonjoin)
            {
                CSteamID judge = (CSteamID)0;
                if (!FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Contains(player.CSteamID))
                {
                    return;
                }
                if (FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Contains(player.CSteamID))
                {
                    if (Instance.Database.IsBanned(player.CSteamID.ToString()))
                    {
                        return;
                    }
                    Instance.Database.BanPlayer(player.CharacterName, player.CSteamID.ToString(), "[TourneyCore]", "[TourneyCore Filter]", 2147483647);
                    SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge, Translate("Filter_Reason"), SteamBlacklist.PERMANENT);
                }
            }
            else
            {
                return;
            }
        }
        public bool Ban(IUserInfo target, IUser bannedBy = null, string reason = null, TimeSpan?duration = null)
        {
            //todo: this is wrong
            var player = ((UnturnedUser)target).Player;

            PlayerBanEvent @event = new PlayerBanEvent(player.User, bannedBy, reason, duration, true);

            eventManager.Emit(host, @event);
            if (@event.IsCancelled)
            {
                return(false);
            }

            if (target is IUser u && u.IsOnline)
            {
                var uPlayer = ((UnturnedUser)target).Player;
                Provider.ban(uPlayer.CSteamID, reason, (uint)(duration?.TotalSeconds ?? uint.MaxValue));
                return(true);
            }

            var steamId  = new CSteamID(ulong.Parse(target.Id));
            var callerId = (bannedBy is UnturnedUser up) ? up.Player.CSteamID : CSteamID.Nil;

            SteamBlacklist.ban(steamId, 0, callerId, reason, (uint)(duration?.TotalSeconds ?? uint.MaxValue));
            return(true);
        }
        public void FixedUpdate()
        {
            //When player connects, run through iteration.
            if (banPlayer)
            {
                //Keep trying to ban player once ping had reached threshold.
                try
                {
                    ping = playerData.Ping;

                    if (ping == 0)
                    {
                        ping = 1;
                    }

                    //Debug.
                    //Logger.Log("Player's ping: " + ping);
                    //Logger.Log("Time Now: " + startTime);
                    //Logger.Log("Total Seconds: " +(DateTime.Now - startTime).TotalSeconds);
                    //Logger.Log("Config Set Grace: " + JailTime.Instance.Configuration.Instance.GracePeriod);
                    //Logger.Log("Grace: " + (JailTime.Instance.Configuration.Instance.GracePeriod + (ping * 10)));

                    if ((DateTime.Now - startTime).TotalSeconds >= JailTime.Instance.Configuration.Instance.GracePeriod + (ping * 10))
                    {
                        //Debug
                        //Logger.Log("Attempt to ban " + playerData.SteamName);

                        //Temp ban.
                        if (JailTime.Instance.Configuration.Instance.BanOnReconnectTime > 0)
                        {
                            SteamBlacklist.ban(playerData.CSteamID, (CSteamID)0UL, JailTime.Instance.Translate("jailtime_ban_time"), JailTime.Instance.Configuration.Instance.BanOnReconnectTime);
                            SteamBlacklist.save();

                            //Debug
                            //Logger.Log("Banned player " + playerData.SteamName + " temporarily. Ban-On-Reconnect.");
                        }

                        //Perma ban.
                        else
                        {
                            SteamBlacklist.ban(playerData.CSteamID, (CSteamID)0L, JailTime.Instance.Translate("jailtime_ban"), 1000000000);
                            SteamBlacklist.save();

                            //Debug
                            //Logger.Log("Banned player " + playerData.SteamName + " permanently. Ban-On-Reconnect.");
                        }

                        banPlayer = false;
                    }
                }
                catch
                {
                    //Nothing to catch, run on next interval
                }
            }
        }
示例#5
0
        public void BanPlayer(UnturnedPlayer player, string reason, int warnings, uint banDuration, IRocketPlayer caller)
        {
            CSteamID judge = (CSteamID)0;

            if (!(caller is ConsolePlayer))
            {
                judge = ((UnturnedPlayer)caller).CSteamID;
            }

            SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge, WarningsPlugin.Instance.Translate("warning_ban_reason", warnings, reason, banDuration),
                               banDuration);
        }
示例#6
0
 private void DeathBan(UnturnedPlayer player)
 {
     if (!player.HasPermission("banondeath.ignore"))
     {
         SteamBlacklist.ban(player.CSteamID, CSteamID.Nil, Configuration.Instance.BanReason, Configuration.Instance.BanLengthSeconds);
         player.Ban(Configuration.Instance.BanReason, Configuration.Instance.BanLengthSeconds);
         Logger.LogWarning($"{player.DisplayName} [{player.Id}] has been banned for {Configuration.Instance.BanLengthSeconds} seconds for dying!");
     }
     else
     {
         Logger.LogWarning("Ignoring Death...");
     }
 }
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            if (!UnturnedPlayer.TryGetPlayer(args[0], out UnturnedPlayer ply))
            {
                UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red);
                return;
            }

            SteamBlacklist.ban(ply.SteamID, ply.SteamIP, ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil, (args.Length > 1 ? args[1] : "Undefined"), SteamBlacklist.PERMANENT);
            if (ply.SteamPlayer.player != null)
            {
                ply.Player.life.askDamage(255, Vector3.up * 101f, EDeathCause.KILL, ELimb.SKULL, ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil, out EPlayerKill ePlayerKill);
            }
            UnturnedChat.SendMessage(executor, string.Format(Translations["Slay_Slay"], ply.PlayerName), ConsoleColor.Red);
        }
        public override void Execute(PointBlankPlayer executor, string[] args)
        {
            uint ip;

            if (!PlayerTool.tryGetSteamID(args[0], out CSteamID player) || (executor != null && ((UnturnedPlayer)executor).SteamID == player))
            {
                UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red);
                return;
            }
            ip = SteamGameServerNetworking.GetP2PSessionState(player, out P2PSessionState_t p2PSessionState_t) ? p2PSessionState_t.m_nRemoteIP : 0u;
            if (args.Length < 2 || uint.TryParse(args[1], out uint duration))
            {
                duration = SteamBlacklist.PERMANENT;
            }
            string reason = args.Length < 3 ? Translations["Ban_Reason"] : args[2];

            SteamBlacklist.ban(player, ip, ((UnturnedPlayer)executor)?.SteamID ?? CSteamID.Nil, reason, duration);
            UnturnedChat.SendMessage(executor, string.Format(Translations["Ban_Success"], player), ConsoleColor.Green);
        }
示例#9
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (caller.DisplayName != "Console")
            {
                UnturnedPlayer pCaller = (UnturnedPlayer)caller;
                if (command.Count() == 3)
                {
                    string playerName = command[0];
                    string reason     = command[1];
                    uint   duration   = (uint)Convert.ToInt32(command[2]);
                    //Find player
                    foreach (SteamPlayer plr in Provider.Players)
                    {
                        //So let's convert each SteamPlayer into an UnturnedPlayer
                        UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);


                        if (unturnedPlayer.DisplayName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CharacterName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.SteamName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CSteamID.ToString().Equals(playerName))
                        {
                            if (CommandModerator.isMod(pCaller))
                            {
                                if (duration > DatasEssentialsManager.Instance.Configuration.Instance.maxBanLength)
                                {
                                    UnturnedChat.Say(caller, "Can't ban longer than " + DatasEssentialsManager.Instance.Configuration.Instance.maxBanLength + " seconds as a moderator.");
                                    return;
                                }

                                DateTime time = DateTime.Now;

                                DatasEssentialsManager.Instance.Configuration.Instance.modKickBanList.Add("[" + time.ToString("M/d/yyyy h:mm:ss tt") + "] Banned " + unturnedPlayer.CharacterName + "(" + unturnedPlayer.CSteamID.ToString() + ") for " + duration + " seconds because " + reason + " by " + pCaller.CharacterName + ".");
                            }

                            SteamBlacklist.ban(unturnedPlayer.CSteamID, pCaller.CSteamID, reason, duration);
                            //         Provider.ban(unturnedPlayer.CSteamID, reason, duration);
                            UnturnedChat.Say(unturnedPlayer.DisplayName + " has been banned for " + reason + " for " + duration + " seconds.", Color.cyan);
                            return;
                        }
                    }
                    UnturnedChat.Say(caller, "Did not find anyone with the name \"" + playerName + "\".", Color.red);
                }
                else
                {
                    UnturnedChat.Say(caller, "Used that wrong, syntax is /ban (player) (reason) (duration seconds)", Color.red);
                }
            }
            else
            {
                if (command.Count() == 3)
                {
                    string playerName = command[0];
                    string reason     = command[1];
                    uint   duration   = (uint)Convert.ToInt32(command[2]);
                    //Find player
                    foreach (SteamPlayer plr in Provider.Players)
                    {
                        //So let's convert each SteamPlayer into an UnturnedPlayer
                        UnturnedPlayer unturnedPlayer = UnturnedPlayer.FromSteamPlayer(plr);


                        if (unturnedPlayer.DisplayName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CharacterName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.SteamName.ToLower().IndexOf(playerName.ToLower()) != -1 || unturnedPlayer.CSteamID.ToString().Equals(playerName))
                        {
                            CSteamID consoleID = new CSteamID(Convert.ToUInt64(0));
                            SteamBlacklist.ban(unturnedPlayer.CSteamID, consoleID, reason, duration);
                            //         Provider.ban(unturnedPlayer.CSteamID, reason, duration);
                            UnturnedChat.Say(unturnedPlayer.DisplayName + " has been banned for " + reason + " for " + duration + " seconds.", Color.cyan);
                            Logger.Log(unturnedPlayer.DisplayName + " (" + unturnedPlayer.CSteamID + ") has been banned for " + reason + " for " + duration + " seconds.");
                            return;
                        }
                    }
                    UnturnedChat.Say(caller, "Did not find anyone with the name \"" + playerName + "\".", Color.red);
                }
                else
                {
                    UnturnedChat.Say(caller, "Used that wrong, syntax is /ban (player) (reason) (duration seconds)", Color.red);
                }
            }
        }
示例#10
0
        public void Execute(IRocketPlayer caller, params string[] param)
        {
            CSteamID judge = (CSteamID)0;

            if (!(caller is ConsolePlayer))
            {
                judge = ((UnturnedPlayer)caller).CSteamID;
            }
            if (param.Length == 0)
            {
                if (Init.Instance.Configuration.Instance.LogIDonjoin)
                {
                    Init.Instance.Configuration.Save();
                    UnturnedChat.Say(caller, "Players already logged when they joined");
                    return;
                }
                else
                {
                    //if logindonjoin false
                    if (Provider.clients.Count == 0)
                    {
                        UnturnedChat.Say(caller, "No one available");
                        return;
                    }
                    else
                    {
                        List <CSteamID> ids = Provider.clients.Select(x => x.playerID.steamID).ToList();


                        if (!ids.Any())
                        {
                            return;
                        }
                        foreach (var player in ids)
                        {
                            FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted = ids.Except(FilterData.FilterData.Instance.Configuration.Instance.Whitelists).ToList();
                            FilterData.FilterData.Instance.Configuration.Save();
                            foreach (var playerid in FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted)
                            {
                                UnturnedChat.Say(caller, playerid.ToString());
                            }

                            UnturnedChat.Say(caller, "IDs saved locally");
                        }
                    }
                }
                return;
            }
            if (param.Length > 0)
            {
                if (param.Length == 1)
                {
                    switch (param[0])
                    {
                    case "debug":

                        if (!FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Any())
                        {
                            UnturnedChat.Say(caller, "Tban list is empty");
                            return;
                        }


                        foreach (var player in FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted)
                        {
                            UnturnedChat.Say(caller, player.ToString());
                        }


                        break;

                    case "unban":



                        if (!FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Any())
                        {
                            UnturnedChat.Say(caller, "Tban list is empty");
                            return;
                        }



                        foreach (var player in FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.ToList())
                        {
                            Init.Instance.Database.UnbanPlayer(player.ToString());

                            SteamBlacklist.unban(player);
                            //CommandWindow.input.onInputText("unban " + player.ToString());
                            UnturnedChat.Say(caller, "Unbanned " + player + " and relieved from Globalban");
                        }

                        break;

                    case "ban":


                        if (!FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Any())
                        {
                            UnturnedChat.Say(caller, "Tban list is empty");
                            return;
                        }
                        else
                        {
                            foreach (var player in FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted)
                            {
                                /*ulong? otherPlayerID = player.GetCSteamID;
                                 * UnturnedPlayer playern = UnturnedPlayer.FromCSteamID(player);*/



                                Init.Instance.Database.BanPlayer("Tourneybanned", player.ToString(), "Tourneyban", "[TourneyCore Filter]", 2147483647);

                                Provider.kick(player, Init.Instance.Translate("Filter_Reason"));
                                SteamBlacklist.ban(player, Init.Instance.GetIP(player), judge, Init.Instance.Translate("Filter_Reason"), 2147483647);


                                UnturnedChat.Say("Kicked " + player);
                                //UnturnedChat.Say(caller, "" + player + " Tourneyban");
                            }
                        }

                        //EArenaState.SPAWN.



                        break;

                    case "enable":
                        if (Init.Instance.Configuration.Instance.LogIDonjoin == true)
                        {
                            UnturnedChat.Say(caller, "Logging on join is already enabled");
                            return;
                        }
                        UnturnedChat.Say(caller, "Enabling logging on join");
                        Init.Instance.Configuration.Instance.LogIDonjoin = true;
                        Init.Instance.Configuration.Save();
                        break;

                    case "disable":
                        if (Init.Instance.Configuration.Instance.LogIDonjoin == false)
                        {
                            UnturnedChat.Say(caller, "Logging on join is already disabled");
                            return;
                        }
                        UnturnedChat.Say(caller, "Disabling logging on join");
                        Init.Instance.Configuration.Instance.LogIDonjoin = false;
                        Init.Instance.Configuration.Save();
                        break;

                    case "clear":
                        if (!FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Any())
                        {
                            UnturnedChat.Say(caller, "List already empty");
                            return;
                        }
                        FilterData.FilterData.Instance.Configuration.Instance.Unwhitelisted.Clear();
                        FilterData.FilterData.Instance.Configuration.Save();
                        UnturnedChat.Say(caller, "Successfully cleared Tban list");
                        break;
                    }
                }
                else
                {
                    UnturnedChat.Say(caller, "Wrong syntax!");
                }
            }



            if (param.Length != 1 && param.Length != 0)
            {
                UnturnedChat.Say(caller, "Wrong syntax");
            }
        }