Example #1
0
        static void DoBan(ModAction e)
        {
            Player who = PlayerInfo.FindExact(e.Target);

            LogAction(e, who, "&8banned");

            if (e.Duration.Ticks != 0)
            {
                string   banner = e.Actor.truename;
                DateTime end    = DateTime.UtcNow.Add(e.Duration);
                Server.tempBans.Update(e.Target, Ban.PackTempBanData(e.Reason, banner, end));
                Server.tempBans.Save();

                if (who != null)
                {
                    who.Kick("Banned for " + e.Duration.Shorten(true) + "." + e.ReasonSuffixed);
                }
            }
            else
            {
                Ban.DeleteBan(e.Target);
                Ban.BanPlayer(e.Actor, e.Target, e.Reason, !e.Announce, e.TargetGroup.Name);
                ModActionCmd.ChangeRank(e.Target, e.targetGroup, Group.BannedRank, who);

                if (who != null)
                {
                    string msg = e.Reason.Length == 0 ? Server.Config.DefaultBanMessage : e.Reason;
                    who.Kick("Banned by " + e.Actor.ColoredName + ": &S" + msg,
                             "Banned by " + e.Actor.ColoredName + ": &f" + msg);
                }
            }
        }
Example #2
0
        void Unban(Player p, string name, Player who)
        {
            string srcFull = p == null ? "(console)" : p.ColoredName + "%S";
            string src     = p == null ? "(console)" : p.name;

            if (Group.findPlayerGroup(name) != Group.findPerm(LevelPermission.Banned))
            {
                foreach (Server.TempBan tban in Server.tempBans)
                {
                    if (!tban.name.CaselessEq(name))
                    {
                        continue;
                    }

                    Server.tempBans.Remove(tban);
                    Player.GlobalMessage(name + " had their temporary ban lifted by " + srcFull + ".");
                    Server.s.Log("UNBANNED: by " + src);
                    Server.IRC.Say(name + " was unbanned by " + src + ".");
                    return;
                }
                Player.SendMessage(p, "Player \"" + name + "\" is not banned.");
            }
            else
            {
                Player.GlobalMessage(name + " was &8(unbanned) %Sby " + srcFull + ".");
                Server.s.Log("UNBANNED: by " + src);
                Server.IRC.Say(name + " was unbanned by " + src + ".");

                Group.findPerm(LevelPermission.Banned).playerList.Remove(name);
                Group.findPerm(LevelPermission.Banned).playerList.Save();
                if (Ban.DeleteBan(name))
                {
                    Player.SendMessage(p, "Deleted ban information about " + name + ".");
                }
                else
                {
                    Player.SendMessage(p, "No info found about " + name + ".");
                }

                if (who != null)
                {
                    who.group = Group.standard; who.color = who.group.color;
                    Entities.GlobalDespawn(who, false);
                    Entities.GlobalSpawn(who, false);
                }
            }
        }
Example #3
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }

            bool stealth = message[0] == '#';

            if (stealth)
            {
                message = message.Remove(0, 1);
                Server.s.Log("Stealth ban Attempted by " + (p == null ? "Console" : p.ColoredName));
            }
            string[] args   = message.SplitSpaces(2);
            string   reason = args.Length > 1 ? args[1] : "";

            string target = RankCmd.FindName(p, "ban", "ban", "", args[0], ref reason);

            if (target == null)
            {
                return;
            }
            Player who = PlayerInfo.FindExact(target);

            if (reason == "")
            {
                reason = Server.defaultBanMessage;
            }
            if (reason == "-")
            {
                reason = "&c-";
            }
            reason = GetReason(p, reason);

            if (reason == null)
            {
                return;
            }
            Group group = who == null?Group.findPlayerGroup(args[0]) : who.group;

            if (!CheckPerms(target, group, p))
            {
                return;
            }

            string banReason = reason == "-" ? "" : " (" + reason + ")";
            string banner    = p == null ? "(console)" : p.ColoredName;
            string banMsg    = null;

            if (who == null)
            {
                banMsg = target + " &f(offline) %Swas &8banned %Sby " + banner + "%S." + banReason;
                Chat.MessageAll(banMsg);
            }
            else
            {
                if (stealth)
                {
                    banMsg = who.ColoredName + " %Swas STEALTH &8banned %Sby " + banner + "%S." + banReason;
                    Chat.MessageOps(banMsg);
                }
                else
                {
                    banMsg = who.ColoredName + " %Swas &8banned %Sby " + banner + "%S." + banReason;
                    Chat.MessageAll(banMsg);
                }
                who.color = "";
            }

            Ban.DeleteBan(target);
            Ban.BanPlayer(p, target, reason, stealth, group.name);
            RankCmd.ChangeRank(target, group, Group.findPerm(LevelPermission.Banned), who);

            if (args.Length == 1)
            {
                Player.AddNote(target, p, "B");
            }
            else
            {
                Player.AddNote(target, p, "B", reason);
            }
            Server.IRC.Say(banMsg);
            Server.s.Log("BANNED: " + target.ToLower() + " by " + banner);
        }
Example #4
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            bool totalUnban = false;

            if (message[0] == '@')
            {
                totalUnban = true;
                message    = message.Remove(0, 1).Trim();
            }

            Player who = PlayerInfo.Find(message);

            if (who == null)
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name.ToLower() == message.ToLower())
                        {
                            if (p != null)
                            {
                                Server.tempBans.Remove(tban);
                                Player.GlobalMessage(message + " has had their temporary ban lifted by " + p.color + p.name + Server.DefaultColor + ".");
                                Server.s.Log("UNBANNED: by " + p.name);
                                Server.IRC.Say(message + " was unbanned by " + p.name + ".");
                                return;
                            }
                            else
                            {
                                Server.tempBans.Remove(tban);
                                Player.GlobalMessage(message + " has had their temporary ban lifted by console.");
                                Server.s.Log("UNBANNED: by console");
                                Server.IRC.Say(message + " was unbanned by console.");
                                return;
                            }
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                if (Group.findPlayerGroup(message) == Group.findPerm(LevelPermission.Banned))
                {
                    if (p != null)
                    {
                        Player.GlobalMessage(message + " was &8(unbanned) %Sby " + p.color + p.name + "%S.");
                        Server.s.Log("UNBANNED: by " + p.name);
                        Server.IRC.Say(message + " was unbanned by " + p.name + ".");
                    }
                    else
                    {
                        Player.GlobalMessage(message + " was &8(unbanned) %Sby (console).");
                        Server.s.Log("UNBANNED: by console");
                        Server.IRC.Say(message + " was unbanned by (console).");
                    }
                    Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
                    if (Ban.DeleteBan(message))
                    {
                        Player.SendMessage(p, "deleted ban information about " + message + ".");
                    }
                    else
                    {
                        Player.SendMessage(p, "no info found about " + message + ".");
                    }
                }
            }
            else
            {
                if (Group.findPlayerGroup(message) != Group.findPerm(LevelPermission.Banned))
                {
                    foreach (Server.TempBan tban in Server.tempBans)
                    {
                        if (tban.name == who.name)
                        {
                            if (p != null)
                            {
                                Server.tempBans.Remove(tban);
                                Player.GlobalMessage(message + " has had their temporary ban lifted by " + p.color + p.name + Server.DefaultColor + ".");
                                Server.s.Log("UNBANNED: by " + p.name);
                                Server.IRC.Say(message + " was unbanned by " + p.name + ".");
                                return;
                            }
                            else
                            {
                                Server.tempBans.Remove(tban);
                                Player.GlobalMessage(message + " has had their temporary ban lifted by console.");
                                Server.s.Log("UNBANNED: by console");
                                Server.IRC.Say(message + " was unbanned by console.");
                                return;
                            }
                        }
                    }
                    Player.SendMessage(p, "Player is not banned.");
                    return;
                }
                if (Group.findPlayerGroup(message) == Group.findPerm(LevelPermission.Banned))
                {
                    if (p != null)
                    {
                        Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by " + p.color + p.name + Server.DefaultColor + ".");
                        Server.s.Log("UNBANNED: by " + p.name);
                        Server.IRC.Say(message + " was unbanned by " + p.name + ".");
                    }
                    else
                    {
                        Player.GlobalMessage(message + " was &8(unbanned)" + Server.DefaultColor + " by console.");
                        Server.s.Log("UNBANNED: by console");
                        Server.IRC.Say(message + " was unbanned by console.");
                    }
                    who.group = Group.standard; who.color = who.group.color;
                    Player.GlobalDespawn(who, false);
                    Player.GlobalSpawn(who, false);
                    Group.findPerm(LevelPermission.Banned).playerList.Remove(message);
                }
            }

            Group.findPerm(LevelPermission.Banned).playerList.Save();
            if (totalUnban)
            {
                Command.all.Find("unbanip").Use(p, "@" + message);
            }
        }