Exemplo n.º 1
0
        static void PardonBad(BadPlayer bad, string who)
        {
            bad.BannedUntil = DateTime.Now;
            SaveBanned();

            Client c = PlayerList.GetPlayerByName(bad.Username);

            if (c != null)
            {
                c.SetWorld(World.Main);
            }

            Log.WritePlayer(bad.Username, " pardoned by " + who);
            Chatting.Parser.Say(Chat.Purple, bad.Username + " unbanned by " + who);
        }
Exemplo n.º 2
0
        public static void Ban(Client admin, string username, DateTime bannedUntil, string reason)
        {
            if (admin != null && admin.Admin(Permissions.Ban) == false)
            {
                admin.TellSystem(Chat.Yellow, "Disabled");
                return;
            }

            if (Donors.IsDonor(username) && bannedUntil < DateTime.Now.AddMinutes(35))
            {
                Log.WritePlayer(username, "Donor not Banned: " + reason);
                if (admin != null)
                {
                    admin.TellSystem(Chat.Gold, "Donor not banned for: " + reason);
                }
                return;
            }

            bool      newban = false;
            BadPlayer b      = GetBanHistory(username);

            if (b == null)
            {
                //Make sure we spelled correctly
                if (admin != null)
                {
                    if (File.Exists("proxy/players/" + Path.GetFileName(username) + ".json") == false)
                    {
                        admin.TellSystem(Chat.Red, "No such player: " + username);
                        return;
                    }
                }

                newban        = true;
                b             = new BadPlayer();
                b.Username    = username;
                b.BannedUntil = bannedUntil;
                b.Reason      = reason;
                lock (blacklist)
                    blacklist.List.Add(b);
            }
            else
            {
                if (b.BannedUntil < DateTime.Now)
                {
                    newban = true;
                }

                //Make sure longer bans are not removed by a shorter violation
                if (b.BannedUntil > bannedUntil)
                {
                    return;
                }
                b.BannedUntil = bannedUntil;
                b.Reason      = reason;
            }
            SaveBanned();

            //Console.WriteLine ("Banning " + b.Username + " for " + b.Reason);
            double banMinutes = (b.BannedUntil - DateTime.Now).TotalMinutes;
            string banlength  = "forever";

            if (banMinutes < 24 * 60 * 30)
            {
                banlength = banMinutes.ToString("0") + " minutes";
            }

            if (admin != null)
            {
                Log.WritePlayer(b.Username, "Banned " + banlength + " by " + admin.MinecraftUsername + ": " + reason);
            }
            else
            {
                Log.WritePlayer(b.Username, "Banned " + banlength + ": " + reason);
            }

            Client pp = PlayerList.GetPlayerByUsernameOrName(username);

            if (pp != null)
            {
                if (newban)
                {
                    Chatting.Parser.Say(Chat.Purple, pp.Name + " is banned " + banlength + ": " + reason);
                }
                if (pp.Session is HellSession == false)
                {
                    pp.SetWorld(World.HellBanned);
                }
            }
            else
            {
                admin.TellSystem(Chat.Purple, username + " was banned(offline): " + reason);
            }
        }