Ejemplo n.º 1
0
        // Player information display.
        //     When used without arguments, shows players's own stats.
        //     An optional argument allows to look at other people's stats.
        internal static void Info( Player player, Command cmd )
        {
            string name = cmd.Next();
            if( name == null ) {
                name = player.name;
            } else if( !player.Can( Permissions.ViewOthersInfo ) ) {
                player.NoAccessMessage( Permissions.ViewOthersInfo );
                return;
            }

            Player target = Server.FindPlayerByNick( name );
            if( target != null && target.nick != target.name ) {
                player.Message( Color.Red, "Warning: Player named " + target.name + " is using a nickname \"" + target.nick + "\"" );
                player.Message( Color.Red, "The information below is for the REAL " + name );
            }

            PlayerInfo info;
            if( !PlayerDB.FindPlayerInfo( name, out info ) ) {
                player.ManyPlayersMessage( name );
            } else if( info != null ) {

                if( DateTime.Now.Subtract( info.lastLoginDate ).TotalDays < 1 ) {
                    player.Message( String.Format( "About {0}: Last login {1:F1} hours ago from {2}",
                                                        info.name,
                                                        DateTime.Now.Subtract( info.lastLoginDate ).TotalHours,
                                                        info.lastIP ) );
                } else {
                    player.Message( String.Format( "About {0}: Last login {1:F1} days ago from {2}",
                                                        info.name,
                                                        DateTime.Now.Subtract( info.lastLoginDate ).TotalDays,
                                                        info.lastIP ) );
                }
                player.Message( String.Format( "  Logged in {0} time(s) since {1:dd MMM yyyy}.",
                                                    info.timesVisited,
                                                    info.firstLoginDate ) );

                player.Message( String.Format( "  Built {0} and deleted {1} blocks, and wrote {2} messages.",
                                                    info.blocksBuilt,
                                                    info.blocksDeleted,
                                                    info.linesWritten ) );

                if( player.info.classChangedBy != "-" ) {
                    player.Message( String.Format( "  Promoted to {0} by {1} on {2:dd MMM yyyy}.",
                                                        info.playerClass.name,
                                                        info.classChangedBy,
                                                        info.classChangeDate ) );
                } else {
                    player.Message( String.Format( "  Class is {0} (default).",
                                                        info.playerClass.name ) );
                }

                TimeSpan totalTime = info.totalTimeOnServer;
                if( Server.FindPlayerExact( player.name ) != null ) {
                    totalTime = totalTime.Add( DateTime.Now.Subtract( info.lastLoginDate ) );
                }
                player.Message( String.Format( "  Spent a total of {0:F1} hours ({1:F1} minutes) here.",
                                                    totalTime.TotalHours,
                                                    totalTime.TotalMinutes ) );
            } else {
                player.NoPlayerMessage( name );
            }
        }
Ejemplo n.º 2
0
 // Shows ban information.
 //     When used without arguments, shows players's own ban stats.
 //     An optional argument allows to look at other people's ban stats.
 internal static void BanInfo( Player player, Command cmd )
 {
     string name = cmd.Next();
     IPAddress address;
     if( name == null ) {
         name = player.name;
     } else if( !player.Can( Permissions.ViewOthersInfo ) ) {
         player.NoAccessMessage( Permissions.ViewOthersInfo );
     } else if( IPAddress.TryParse( name, out address ) ) {
         IPBanInfo info = IPBanList.Get( address );
         if( info != null ) {
             player.Message( String.Format( "{0} was banned by {1} on {2:dd MMM yyyy}.",
                                                 info.address,
                                                 info.bannedBy,
                                                 info.banDate ) );
             if( info.playerName != null ) {
                 player.Message( "  IP ban was banned by association with " + info.playerName );
             }
             if( info.attempts > 0 ) {
                 player.Message( "  There have been " + info.attempts + " attempts to log in, most recently" );
                 player.Message( String.Format( "  on {0:dd MMM yyyy} by {1}.",
                                                     info.lastAttemptDate,
                                                     info.lastAttemptName ) );
             }
             if( info.banReason != "" ) {
                 player.Message( "  Memo: " + info.banReason );
             }
         } else {
             player.Message( address.ToString() + " is currently NOT banned." );
         }
     } else {
         PlayerInfo info;
         if( !PlayerDB.FindPlayerInfo( name, out info ) ) {
             player.ManyPlayersMessage( name );
         } else if( info != null ) {
             if( info.banned ) {
                 player.Message( "Player " + info.name + " is currently " + Color.Red + "banned." );
             } else {
                 player.Message( "Player " + info.name + " is currently NOT banned." );
             }
             if( info.bannedBy != "-" ) {
                 player.Message( String.Format( "  Last banned by {0} on {1:dd MMM yyyy}.",
                                                     info.bannedBy,
                                                     info.banDate ) );
                 if( info.banReason != "" ) {
                     player.Message( "  Ban memo: " + info.banReason );
                 }
             }
             if( info.unbannedBy != "-" ) {
                 player.Message( String.Format( "  Unbanned by {0} on {1:dd MMM yyyy}.",
                                                     info.unbannedBy,
                                                     info.unbanDate ) );
                 if( info.unbanReason != "" ) {
                     player.Message( "  Unban memo: " + info.unbanReason );
                 }
             }
             if( info.banDate != DateTime.MinValue ) {
                 TimeSpan banDuration;
                 if( info.banned ) {
                     banDuration = DateTime.Now.Subtract( info.banDate );
                 } else {
                     banDuration = info.unbanDate.Subtract( info.banDate );
                 }
                 player.Message( String.Format( "  Last ban duration: {0} days and {1:F1} hours.",
                                                     (int)banDuration.TotalDays,
                                                     banDuration.TotalHours ) );
             }
         } else {
             player.NoPlayerMessage( name );
         }
     }
 }