コード例 #1
0
        static void DoUnban(ModAction e)
        {
            Player who = PlayerInfo.FindExact(e.Target);

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

            if (Server.tempBans.Remove(e.Target))
            {
                Server.tempBans.Save();
            }
            if (!Group.BannedRank.Players.Contains(e.Target))
            {
                return;
            }

            Ban.DeleteUnban(e.Target);
            Ban.UnbanPlayer(e.Actor, e.Target, e.Reason);
            ModActionCmd.ChangeRank(e.Target, Group.BannedRank, Group.DefaultRank, who, false);

            string ip = PlayerDB.FindIP(e.Target);

            if (ip != null && Server.bannedIP.Contains(ip))
            {
                e.Actor.Message("NOTE: Their IP is still banned.");
            }
        }
コード例 #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (CheckSuper(p, message, "player name"))
            {
                return;
            }
            if (message.Length == 0)
            {
                message = p.name;
            }

            string plName = PlayerInfo.FindMatchesPreferOnline(p, message);

            if (plName == null)
            {
                return;
            }
            string nick = p.FormatNick(plName);

            string   tempData = Server.tempBans.FindData(plName);
            string   tempBanner = null, tempReason = null;
            DateTime tempExpiry = DateTime.MinValue;

            if (tempData != null)
            {
                Ban.UnpackTempBanData(tempData, out tempReason, out tempBanner, out tempExpiry);
            }

            bool   permaBanned = Group.BannedRank.Players.Contains(plName);
            bool   isBanned    = permaBanned || tempExpiry >= DateTime.UtcNow;
            string msg         = nick;
            string ip          = PlayerDB.FindIP(plName);
            bool   ipBanned    = ip != null && Server.bannedIP.Contains(ip);

            if (!ipBanned && isBanned)
            {
                msg += " &Sis &cBANNED";
            }
            else if (!ipBanned && !isBanned)
            {
                msg += " &Sis not banned";
            }
            else if (ipBanned && isBanned)
            {
                msg += " &Sand their IP are &cBANNED";
            }
            else
            {
                msg += " &Sis not banned, but their IP is &cBANNED";
            }

            string   banner, reason, prevRank;
            DateTime time;

            Ban.GetBanData(plName, out banner, out reason, out time, out prevRank);
            if (banner != null && permaBanned)
            {
                string grpName = Group.GetColoredName(prevRank);
                msg += " &S(Former rank: " + grpName + "&S)";
            }
            p.Message(msg);

            if (tempExpiry >= DateTime.UtcNow)
            {
                TimeSpan delta = tempExpiry - DateTime.UtcNow;
                p.Message("Temp-banned &S by {1} &Sfor another {0}",
                          delta.Shorten(), GetName(p, tempBanner));
                if (tempReason.Length > 0)
                {
                    p.Message("Reason: {0}", tempReason);
                }
            }

            if (banner != null)
            {
                DisplayDetails(p, banner, reason, time, permaBanned ? "Banned" : "Last banned");
            }
            else
            {
                p.Message("No previous bans recorded for {0}&S.", nick);
            }
            Ban.GetUnbanData(plName, out banner, out reason, out time);
            DisplayDetails(p, banner, reason, time, permaBanned ? "Last unbanned" : "Unbanned");
        }