Example #1
0
        static void PlayerSomethingMessage(Player player, string action, PlayerInfo target, string reason)
        {
            string message = String.Format("{0}&W* {1}&W was {2} by {3}&W",
                                           Color.IRCBold,
                                           target.GetClassyName(),
                                           action,
                                           player.GetClassyName());

            if (!String.IsNullOrEmpty(reason))
            {
                message += " Reason: " + reason;
            }
            if (ConfigKey.IRCBotAnnounceServerEvents.GetBool())
            {
                SendAction(message);
            }
        }
Example #2
0
        public static void PrintPlayerInfo( Player player, PlayerInfo info ) {
            Player target = Server.FindPlayerExact( info.Name );

            // hide online status when hidden
            if( target != null && !player.CanSee( target ) ) {
                target = null;
            }

            if( info.LastIP.Equals( IPAddress.None ) ) {
                player.Message( "About {0}&S: Never seen before.", info.GetClassyName() );

            } else {
                if( target != null ) {
                    if( target.IsHidden ) {
                        if( player.Can( Permission.ViewPlayerIPs ) ) {
                            player.Message( "About {0}&S: HIDDEN. Online from {1}",
                                            info.GetClassyName(),
                                            info.LastIP );
                        } else {
                            player.Message( "About {0}&S: HIDDEN.",
                                            info.GetClassyName() );
                        }
                    } else {
                        if( player.Can( Permission.ViewPlayerIPs ) ) {
                            player.Message( "About {0}&S: Online now from {1}",
                                            info.GetClassyName(),
                                            info.LastIP );
                        } else {
                            player.Message( "About {0}&S: Online now.",
                                            info.GetClassyName() );
                        }
                    }
                } else {
                    if( player.Can( Permission.ViewPlayerIPs ) ) {
                        player.Message( "About {0}&S: Last seen {1} ago from {2}",
                                        info.GetClassyName(),
                                        info.TimeSinceLastSeen.ToMiniString(),
                                        info.LastIP );
                    } else {
                        player.Message( "About {0}&S: Last seen {1} ago.",
                                        info.GetClassyName(),
                                        info.TimeSinceLastSeen.ToMiniString() );
                    }
                }
                // Show login information
                player.Message( "  Logged in {0} time(s) since {1:d MMM yyyy}.",
                                info.TimesVisited,
                                info.FirstLoginDate );
            }


            // Show ban information
            IPBanInfo ipBan = IPBanList.Get( info.LastIP );
            if( ipBan != null && info.Banned ) {
                player.Message( "  Both name and IP are {0}BANNED&S. See &H/baninfo", Color.Red );
            } else if( ipBan != null ) {
                player.Message( "  IP is {0}BANNED&S (but nick isn't). See &H/baninfo", Color.Red );
            } else if( info.Banned ) {
                player.Message( "  Nick is {0}BANNED&S (but IP isn't). See &H/baninfo", Color.Red );
            }


            if( info.LastIP.ToString() != IPAddress.None.ToString() ) {
                // Show alts
                List<PlayerInfo> altNames = new List<PlayerInfo>();
                int bannedAltCount = 0;
                foreach( PlayerInfo playerFromSameIP in PlayerDB.FindPlayers( info.LastIP, 25 ) ) {
                    if( playerFromSameIP != info ) {
                        altNames.Add( playerFromSameIP );
                        if( playerFromSameIP.Banned ) {
                            bannedAltCount++;
                        }
                    }
                }

                if( altNames.Count > 0 ) {
                    if( bannedAltCount > 0 ) {
                        player.Message( "  {0} accounts ({1} banned) share this IP: {2}",
                                        altNames.Count,
                                        bannedAltCount,
                                        altNames.ToArray().JoinToClassyString() );
                    } else {
                        player.Message( "  {0} accounts share this IP: {1}",
                                        altNames.Count,
                                        altNames.ToArray().JoinToClassyString() );
                    }
                }
            }


            // Stats
            if( info.BlocksDrawn > 500000000 ) {
                player.Message( "  Built {0} and deleted {1} blocks, drew {2}M blocks, wrote {3} messages.",
                                info.BlocksBuilt,
                                info.BlocksDeleted,
                                info.BlocksDrawn / 1000000,
                                info.LinesWritten );
            } else if( info.BlocksDrawn > 500000 ) {
                player.Message( "  Built {0} and deleted {1} blocks, drew {2}K blocks, wrote {3} messages.",
                                info.BlocksBuilt,
                                info.BlocksDeleted,
                                info.BlocksDrawn / 1000,
                                info.LinesWritten );
            } else if( info.BlocksDrawn > 0 ) {
                player.Message( "  Built {0} and deleted {1} blocks, drew {2} blocks, wrote {3} messages.",
                                info.BlocksBuilt,
                                info.BlocksDeleted,
                                info.BlocksDrawn,
                                info.LinesWritten );
            } else {
                player.Message( "  Built {0} and deleted {1} blocks, wrote {2} messages.",
                                info.BlocksBuilt,
                                info.BlocksDeleted,
                                info.LinesWritten );
            }


            // More stats
            if( info.TimesBannedOthers > 0 || info.TimesKickedOthers > 0 ) {
                player.Message( "  Kicked {0} and banned {1} players.", info.TimesKickedOthers, info.TimesBannedOthers );
            }

            if( info.TimesKicked > 0 ) {
                if( info.LastKickDate != DateTime.MinValue ) {
                    player.Message( "  Got kicked {0} times. Last kick {1} ago by {2}",
                                    info.TimesKicked,
                                    info.TimeSinceLastKick.ToMiniString(),
                                    info.LastKickBy );
                    if( info.LastKickReason.Length > 0 ) {
                        player.Message( "  Last kick reason: {0}", info.LastKickReason );
                    }
                } else {
                    player.Message( "  Got kicked {0} times", info.TimesKicked );
                }
            }


            // Promotion/demotion
            if( !String.IsNullOrEmpty( info.RankChangedBy ) ) {
                if( info.PreviousRank == null ) {
                    player.Message( "  Promoted to {0}&S by {1} {2} ago.",
                                    info.Rank.GetClassyName(),
                                    info.RankChangedBy,
                                    info.TimeSinceRankChange.ToMiniString() );
                } else if( info.PreviousRank < info.Rank ) {
                    player.Message( "  Promoted from {0}&S to {1}&S by {2} {3} ago.",
                                    info.PreviousRank.GetClassyName(),
                                    info.Rank.GetClassyName(),
                                    info.RankChangedBy,
                                    info.TimeSinceRankChange.ToMiniString() );
                    if( !string.IsNullOrEmpty( info.RankChangeReason ) ) {
                        player.Message( "  Promotion reason: {0}", info.RankChangeReason );
                    }
                } else {
                    player.Message( "  Demoted from {0}&S to {1}&S by {2} {3} ago.",
                                    info.PreviousRank.GetClassyName(),
                                    info.Rank.GetClassyName(),
                                    info.RankChangedBy,
                                    info.TimeSinceRankChange.ToMiniString() );
                    if( info.RankChangeReason.Length > 0 ) {
                        player.Message( "  Demotion reason: {0}", info.RankChangeReason );
                    }
                }
            } else {
                player.Message( "  Rank is {0}&S (default).",
                                info.Rank.GetClassyName() );
            }

            if( info.LastIP.ToString() != IPAddress.None.ToString() ) {
                // Time on the server
                TimeSpan totalTime = info.TotalTime;
                if( target != null ) {
                    totalTime = totalTime.Add( info.TimeSinceLastLogin );
                }
                player.Message( "  Spent a total of {0:F1} hours ({1:F1} minutes) here.",
                                totalTime.TotalHours,
                                totalTime.TotalMinutes );
            }
        }
Example #3
0
        public static void PrintPlayerInfo(Player player, PlayerInfo info)
        {
            Player target = Server.FindPlayerExact(info.Name);

            // hide online status when hidden
            if (target != null && !player.CanSee(target))
            {
                target = null;
            }

            if (info.LastIP.Equals(IPAddress.None))
            {
                player.Message("About {0}&S: Never seen before.", info.GetClassyName());
            }
            else
            {
                if (target != null)
                {
                    if (target.IsHidden)
                    {
                        if (player.Can(Permission.ViewPlayerIPs))
                        {
                            player.Message("About {0}&S: HIDDEN. Online from {1}",
                                           info.GetClassyName(),
                                           info.LastIP);
                        }
                        else
                        {
                            player.Message("About {0}&S: HIDDEN.",
                                           info.GetClassyName());
                        }
                    }
                    else
                    {
                        if (player.Can(Permission.ViewPlayerIPs))
                        {
                            player.Message("About {0}&S: Online now from {1}",
                                           info.GetClassyName(),
                                           info.LastIP);
                        }
                        else
                        {
                            player.Message("About {0}&S: Online now.",
                                           info.GetClassyName());
                        }
                    }
                }
                else
                {
                    if (player.Can(Permission.ViewPlayerIPs))
                    {
                        player.Message("About {0}&S: Last seen {1} ago from {2}",
                                       info.GetClassyName(),
                                       info.TimeSinceLastSeen.ToMiniString(),
                                       info.LastIP);
                    }
                    else
                    {
                        player.Message("About {0}&S: Last seen {1} ago.",
                                       info.GetClassyName(),
                                       info.TimeSinceLastSeen.ToMiniString());
                    }
                }
                // Show login information
                player.Message("  Logged in {0} time(s) since {1:d MMM yyyy}.",
                               info.TimesVisited,
                               info.FirstLoginDate);
            }


            // Show ban information
            IPBanInfo ipBan = IPBanList.Get(info.LastIP);

            if (ipBan != null && info.Banned)
            {
                player.Message("  Both name and IP are {0}BANNED&S. See &H/baninfo", Color.Red);
            }
            else if (ipBan != null)
            {
                player.Message("  IP is {0}BANNED&S (but nick isn't). See &H/baninfo", Color.Red);
            }
            else if (info.Banned)
            {
                player.Message("  Nick is {0}BANNED&S (but IP isn't). See &H/baninfo", Color.Red);
            }


            if (info.LastIP.ToString() != IPAddress.None.ToString())
            {
                // Show alts
                List <PlayerInfo> altNames = new List <PlayerInfo>();
                int bannedAltCount         = 0;
                foreach (PlayerInfo playerFromSameIP in PlayerDB.FindPlayers(info.LastIP, 25))
                {
                    if (playerFromSameIP != info)
                    {
                        altNames.Add(playerFromSameIP);
                        if (playerFromSameIP.Banned)
                        {
                            bannedAltCount++;
                        }
                    }
                }

                if (altNames.Count > 0)
                {
                    if (bannedAltCount > 0)
                    {
                        player.Message("  {0} accounts ({1} banned) share this IP: {2}",
                                       altNames.Count,
                                       bannedAltCount,
                                       altNames.ToArray().JoinToClassyString());
                    }
                    else
                    {
                        player.Message("  {0} accounts share this IP: {1}",
                                       altNames.Count,
                                       altNames.ToArray().JoinToClassyString());
                    }
                }
            }


            // Stats
            if (info.BlocksDrawn > 500000000)
            {
                player.Message("  Built {0} and deleted {1} blocks, drew {2}M blocks, wrote {3} messages.",
                               info.BlocksBuilt,
                               info.BlocksDeleted,
                               info.BlocksDrawn / 1000000,
                               info.LinesWritten);
            }
            else if (info.BlocksDrawn > 500000)
            {
                player.Message("  Built {0} and deleted {1} blocks, drew {2}K blocks, wrote {3} messages.",
                               info.BlocksBuilt,
                               info.BlocksDeleted,
                               info.BlocksDrawn / 1000,
                               info.LinesWritten);
            }
            else if (info.BlocksDrawn > 0)
            {
                player.Message("  Built {0} and deleted {1} blocks, drew {2} blocks, wrote {3} messages.",
                               info.BlocksBuilt,
                               info.BlocksDeleted,
                               info.BlocksDrawn,
                               info.LinesWritten);
            }
            else
            {
                player.Message("  Built {0} and deleted {1} blocks, wrote {2} messages.",
                               info.BlocksBuilt,
                               info.BlocksDeleted,
                               info.LinesWritten);
            }


            // More stats
            if (info.TimesBannedOthers > 0 || info.TimesKickedOthers > 0)
            {
                player.Message("  Kicked {0} and banned {1} players.", info.TimesKickedOthers, info.TimesBannedOthers);
            }

            if (info.TimesKicked > 0)
            {
                if (info.LastKickDate != DateTime.MinValue)
                {
                    player.Message("  Got kicked {0} times. Last kick {1} ago by {2}",
                                   info.TimesKicked,
                                   info.TimeSinceLastKick.ToMiniString(),
                                   info.LastKickBy);
                    if (info.LastKickReason.Length > 0)
                    {
                        player.Message("  Last kick reason: {0}", info.LastKickReason);
                    }
                }
                else
                {
                    player.Message("  Got kicked {0} times", info.TimesKicked);
                }
            }


            // Promotion/demotion
            if (!String.IsNullOrEmpty(info.RankChangedBy))
            {
                if (info.PreviousRank == null)
                {
                    player.Message("  Promoted to {0}&S by {1} {2} ago.",
                                   info.Rank.GetClassyName(),
                                   info.RankChangedBy,
                                   info.TimeSinceRankChange.ToMiniString());
                }
                else if (info.PreviousRank < info.Rank)
                {
                    player.Message("  Promoted from {0}&S to {1}&S by {2} {3} ago.",
                                   info.PreviousRank.GetClassyName(),
                                   info.Rank.GetClassyName(),
                                   info.RankChangedBy,
                                   info.TimeSinceRankChange.ToMiniString());
                    if (!string.IsNullOrEmpty(info.RankChangeReason))
                    {
                        player.Message("  Promotion reason: {0}", info.RankChangeReason);
                    }
                }
                else
                {
                    player.Message("  Demoted from {0}&S to {1}&S by {2} {3} ago.",
                                   info.PreviousRank.GetClassyName(),
                                   info.Rank.GetClassyName(),
                                   info.RankChangedBy,
                                   info.TimeSinceRankChange.ToMiniString());
                    if (info.RankChangeReason.Length > 0)
                    {
                        player.Message("  Demotion reason: {0}", info.RankChangeReason);
                    }
                }
            }
            else
            {
                player.Message("  Rank is {0}&S (default).",
                               info.Rank.GetClassyName());
            }

            if (info.LastIP.ToString() != IPAddress.None.ToString())
            {
                // Time on the server
                TimeSpan totalTime = info.TotalTime;
                if (target != null)
                {
                    totalTime = totalTime.Add(info.TimeSinceLastLogin);
                }
                player.Message("  Spent a total of {0:F1} hours ({1:F1} minutes) here.",
                               totalTime.TotalHours,
                               totalTime.TotalMinutes);
            }
        }
Example #4
0
 public string GetClassyName()
 {
     return(Info.GetClassyName());
 }