Example #1
0
        WhoInfo FromOnline(Player who)
        {
            WhoInfo info   = new WhoInfo();
            string  prefix = who.title == "" ? "" : who.color + "[" + who.titlecolor + who.title + who.color + "] ";

            info.FullName = prefix + who.ColoredName;
            info.Name     = who.name;
            info.Group    = who.group;
            info.Money    = who.money; info.Deaths = who.overallDeath;

            info.TotalBlocks = who.overallBlocks; info.TotalDrawn = who.TotalDrawn;
            info.TotalPlaced = who.TotalPlaced; info.TotalDeleted = who.TotalDeleted;
            info.LoginBlocks = who.loginBlocks;

            info.TimeSpent = who.time; info.TimeOnline = DateTime.Now - who.timeLogged;
            info.First     = who.firstLogin;
            info.Logins    = who.totalLogins; info.Kicks = who.totalKicked;
            info.IP        = who.ip; info.AfkMessage = who.afkMessage;
            info.IdleTime  = DateTime.UtcNow - who.LastAction;

            info.RoundsTotal   = who.Game.TotalRoundsSurvived;
            info.RoundsMax     = who.Game.MaxRoundsSurvived;
            info.InfectedTotal = who.Game.TotalInfected;
            info.InfectedMax   = who.Game.MaxInfected;
            return(info);
        }
Example #2
0
        public override void Use(Player p, string message)
        {
            Player who = message == "" ? p : PlayerInfo.Find(message);

            if (message == "")
            {
                message = p.name;
            }
            if (who == null || !Entities.CanSee(p, who))
            {
                Player.SendMessage(p, "\"" + message + "\" is offline! Using /whowas instead.");
                Command.all.Find("whowas").Use(p, message); return;
            }

            WhoInfo info   = new WhoInfo();
            string  prefix = who.title == "" ? "" : "[" + who.titlecolor + who.title + who.color + "] ";

            info.FullName    = prefix + who.ColoredName;
            info.Name        = who.name;
            info.Group       = who.group;
            info.Money       = who.money; info.Deaths = who.overallDeath;
            info.TotalBlocks = who.overallBlocks; info.LoginBlocks = who.loginBlocks;
            info.TimeSpent   = who.time; info.TimeOnline = DateTime.Now - who.timeLogged;
            info.First       = who.firstLogin;
            info.Logins      = who.totalLogins; info.Kicks = who.totalKicked;
            info.IP          = who.ip;

            info.RoundsTotal   = who.Game.TotalRoundsSurvived;
            info.RoundsMax     = who.Game.MaxRoundsSurvived;
            info.InfectedTotal = who.Game.TotalInfected;
            info.InfectedMax   = who.Game.MaxInfected;
            WhoInfo.Output(p, info, CheckAdditionalPerm(p));
        }
Example #3
0
        WhoInfo FromOffline(PlayerData data, string message)
        {
            Group  group  = Group.findPlayerGroup(data.Name);
            string color  = data.Color == "" ? group.color : data.Color;
            string prefix = data.Title == "" ? "" : color + "[" + data.TitleColor + data.Title + color + "] ";

            WhoInfo info = new WhoInfo();

            info.FullName = prefix + color + data.Name.TrimEnd('+');
            info.Name     = data.Name;
            info.Group    = group;
            info.Money    = data.Money; info.Deaths = data.Deaths;

            info.TotalBlocks = data.TotalModified; info.TotalDrawn = data.TotalDrawn;
            info.TotalPlaced = data.TotalPlaced; info.TotalDeleted = data.TotalDeleted;
            info.LoginBlocks = -1;

            info.TimeSpent = data.TotalTime.ParseDBTime();
            info.First     = data.FirstLogin;
            info.Last      = data.LastLogin;
            info.Logins    = data.Logins; info.Kicks = data.Kicks;
            info.IP        = data.IP;

            if (Server.zombie.Running)
            {
                ZombieStats stats = Server.zombie.LoadZombieStats(data.Name);
                info.RoundsTotal = stats.TotalRounds; info.InfectedTotal = stats.TotalInfected;
                info.RoundsMax   = stats.MaxRounds; info.InfectedMax = stats.MaxInfected;
            }
            return(info);
        }
Example #4
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                Help(p); return;
            }
            int    matches;
            Player pl = PlayerInfo.FindOrShowMatches(p, message, out matches);

            if (matches > 1)
            {
                return;
            }
            if (matches == 1)
            {
                Player.SendMessage(p, pl.color + pl.name + " %Sis online, using /whois instead.");
                Command.all.Find("whois").Use(p, message); return;
            }

            if (!Player.ValidName(message))
            {
                Player.SendMessage(p, "\"" + message + "\" is not a valid player name."); return;
            }
            OfflinePlayer target = PlayerInfo.FindOffline(message, true);

            if (target == null)
            {
                Player.SendMessage(p, "\"" + message + "\" was not found in the database.");
                Player.SendMessage(p, "Note you must use a player's full account name."); return;
            }

            Group  group  = Group.Find(Group.findPlayer(message));
            string color  = target.color == "" ? group.color : target.color;
            string prefix = target.title == "" ? "" : "[" + target.titleColor + target.title + color + "] ";

            WhoInfo info = new WhoInfo();

            info.FullName    = prefix + color + target.name.TrimEnd('+');
            info.Name        = target.name;
            info.Group       = group;
            info.Money       = int.Parse(target.money); info.Deaths = int.Parse(target.deaths);
            info.TotalBlocks = long.Parse(target.blocks); info.LoginBlocks = -1;
            info.TimeSpent   = target.totalTime.ParseDBTime();
            info.First       = DateTime.Parse(target.firstLogin);
            info.Last        = DateTime.Parse(target.lastLogin);
            info.Logins      = int.Parse(target.logins); info.Kicks = int.Parse(target.kicks);
            info.IP          = target.ip;

            if (Server.zombie.Running)
            {
                ZombieStats stats = Server.zombie.LoadZombieStats(target.name);
                info.RoundsTotal = stats.TotalRounds; info.InfectedTotal = stats.TotalInfected;
                info.RoundsMax   = stats.MaxRounds; info.InfectedMax = stats.MaxInfected;
            }
            WhoInfo.Output(p, info, CheckAdditionalPerm(p));
        }
Example #5
0
        public override void Use(Player p, string message)
        {
            if (message == "")
            {
                message = p.name;
            }
            int    matches;
            Player pl = PlayerInfo.FindMatches(p, message, out matches);

            if (matches > 1)
            {
                return;
            }

            WhoInfo info;

            if (matches == 1)
            {
                info = FromOnline(pl);
            }
            else
            {
                if (!Formatter.ValidName(p, message, "player"))
                {
                    return;
                }
                Player.Message(p, "Searching database for the player..");
                PlayerData target = PlayerInfo.FindOfflineMatches(p, message);
                if (target == null)
                {
                    return;
                }
                info = FromOffline(target, message);
            }
            WhoInfo.Output(p, info, CheckExtraPerm(p));
        }
Example #6
0
        public static void Output(Player p, WhoInfo who, bool canSeeIP)
        {
            Player.SendMessage(p, who.FullName + " %S(" + who.Name + ") has:");
            Player.SendMessage(p, ">> Rank of " + who.Group.ColoredName);

            if (Economy.Enabled)
            {
                Player.SendMessage(p, ">> &a" + who.Deaths + " &cdeaths%S, &a" + who.Money +
                                   " %S" + Server.moneys + ", " + Awards.AwardAmount(who.Name) + " awards");
            }
            else
            {
                Player.SendMessage(p, ">> &a" + who.Deaths + " &cdeaths%s, " + Awards.AwardAmount(who.Name) + " awards");
            }

            if (who.LoginBlocks >= 0)
            {
                Player.SendMessage(p, ">> &bModified &a" + who.TotalBlocks + " &eblocks, &a" + who.LoginBlocks + " &esince login");
            }
            else
            {
                Player.SendMessage(p, ">> &bModified &a" + who.TotalBlocks + " &eblocks");
            }

            if (who.TimeOnline.Ticks > 0)
            {
                Player.SendMessage(p, ">> Spent " + Shorten(who.TimeSpent) + " on the server, " + Shorten(who.TimeOnline) + " this session");
            }
            else
            {
                Player.SendMessage(p, ">> Spent " + Shorten(who.TimeSpent) + " on the server");
            }

            if (who.Last.Ticks > 0)
            {
                Player.SendMessage(p, ">> First login &a" + who.First.ToString("yyyy-MM-dd")
                                   + "%S, last login &a" + who.Last.ToString("yyyy-MM-dd"));
            }
            else
            {
                Player.SendMessage(p, ">> First login on &a" + who.First.ToString("yyyy-MM-dd")
                                   + "%S, and is currently &aonline");
            }

            Player.SendMessage(p, ">> Logged in &a" + who.Logins + " %Stimes, &c" + who.Kicks + " %Sof which ended in a kick");
            string[] data = Ban.GetBanData(who.Name);
            if (data != null)
            {
                Player.SendMessage(p, ">> is banned for " + data[1] + " by " + data[0]);
            }

            if (Server.Devs.CaselessContains(who.Name))
            {
                Player.SendMessage(p, ">> Player is a &9Developer");
            }
            if (Server.Mods.CaselessContains(who.Name))
            {
                Player.SendMessage(p, ">> Player is a &9MCGalaxy Moderator");
            }

            if (canSeeIP)
            {
                string ipMsg = who.IP;
                if (Server.bannedIP.Contains(who.IP))
                {
                    ipMsg = "&8" + who.IP + ", which is banned";
                }
                Player.SendMessage(p, ">> The IP of " + ipMsg);
                if (Server.useWhitelist && Server.whiteList.Contains(who.Name))
                {
                    Player.SendMessage(p, ">> Player is &fWhitelisted");
                }
            }

            if (!Server.zombie.Running)
            {
                return;
            }
            Player.SendMessage(p, ">> Survived &a" + who.RoundsTotal +
                               " %Srounds total, most in a row was &e" + who.RoundsMax);
            Player.SendMessage(p, ">> Infected &a" + who.InfectedTotal +
                               " %Splayers total, most in a round was &e" + who.InfectedMax);
        }
Example #7
0
        public static void Output(Player p, WhoInfo who, bool canSeeIP)
        {
            Player.Message(p, who.FullName + " %S(" + who.Name + ") has:");
            Player.Message(p, "  Rank of " + who.Group.ColoredName);

            if (Economy.Enabled)
            {
                Player.Message(p, "  &a{0} &cdeaths%S, &a{2} %S{3}, {1} %Sawards",
                               who.Deaths, Awards.AwardAmount(who.Name), who.Money, Server.moneys);
            }
            else
            {
                Player.Message(p, "  &a{0} &cdeaths%S, {1} %Sawards",
                               who.Deaths, Awards.AwardAmount(who.Name));
            }

            if (who.LoginBlocks >= 0)
            {
                Player.Message(p, "  Modified &a{0} %Sblocks, &a{1} %Ssince login", who.TotalBlocks, who.LoginBlocks);
            }
            else
            {
                Player.Message(p, "  Modified &a{0} %Sblocks", who.TotalBlocks);
            }
            Player.Message(p, "    &a{0} %Splaced, &a{1} %Sdeleted, &a{2} %Sdrawn",
                           who.TotalPlaced, who.TotalDeleted, who.TotalDrawn);

            if (who.TimeOnline.Ticks > 0)
            {
                Player.Message(p, "  Spent &a{0} %Son the server, &a{1} %Sthis session",
                               who.TimeSpent.Shorten(), who.TimeOnline.Shorten());
            }
            else
            {
                Player.Message(p, "  Spent &a{0} %Son the server", who.TimeSpent.Shorten());
            }

            if (who.Last.Ticks > 0)
            {
                Player.Message(p, "  First login &a" + who.First.ToString("yyyy-MM-dd")
                               + "%S, last login &a" + who.Last.ToString("yyyy-MM-dd"));
            }
            else
            {
                Player.Message(p, "  First login on &a" + who.First.ToString("yyyy-MM-dd")
                               + "%S, and is currently &aonline");
            }

            Player.Message(p, "  Logged in &a{0} %Stimes, &c{1} %Sof which ended in a kick", who.Logins, who.Kicks);
            if (who.Group.Permission == LevelPermission.Banned)
            {
                string[] data = Ban.GetBanData(who.Name);
                if (data != null)
                {
                    Player.Message(p, "  Banned for {0} by {1}",
                                   data[1], PlayerInfo.GetColoredName(p, data[0]));
                }
                else
                {
                    Player.Message(p, "  Is banned");
                }
            }

            if (Server.Devs.CaselessContains(who.Name.TrimEnd('+')))
            {
                Player.Message(p, "  Player is an &9MCGalaxy Developer");
            }
            if (Server.Mods.CaselessContains(who.Name.TrimEnd('+')))
            {
                Player.Message(p, "  Player is an &9MCGalaxy Moderator");
            }

            if (canSeeIP)
            {
                string ipMsg = who.IP;
                if (Server.bannedIP.Contains(who.IP))
                {
                    ipMsg = "&8" + who.IP + ", which is banned";
                }
                Player.Message(p, "  The IP of " + ipMsg);
                if (Server.useWhitelist && Server.whiteList.Contains(who.Name))
                {
                    Player.Message(p, "  Player is &fWhitelisted");
                }
            }

            if (who.AfkMessage != null)
            {
                Player.Message(p, "  Idle for {0} (AFK {1}%S)", who.IdleTime.Shorten(), who.AfkMessage);
            }
            else if (who.IdleTime.TotalMinutes >= 1)
            {
                Player.Message(p, "  Idle for {0}", who.IdleTime.Shorten());
            }

            if (!Server.zombie.Running)
            {
                return;
            }
            Player.Message(p, "  Survived &a{0} %Srounds (max &e{1}%S)",
                           who.RoundsTotal, who.RoundsMax);
            Player.Message(p, "  Infected &a{0} %Splayers (max &e{1}%S)",
                           who.InfectedTotal, who.InfectedMax);
        }