@@ -16,7 +16,7 @@ static class InfoCommands {
1616 const int PlayersPerPage = 30 ;
1717 internal static void Init ( ) {
1818 CommandManager . RegisterCommand ( CdInfo ) ;
19- CommandManager . RegisterCommand ( CdWhoIs ) ;
19+ CommandManager . RegisterCommand ( CdWhoNick ) ;
2020 CommandManager . RegisterCommand ( CdBanInfo ) ;
2121 CommandManager . RegisterCommand ( CdRankInfo ) ;
2222 CommandManager . RegisterCommand ( CdServerInfo ) ;
@@ -122,7 +122,7 @@ static void BDBDBHandler(Player player, CommandReader cmd)
122122
123123 static readonly CommandDescriptor CdInfo = new CommandDescriptor {
124124 Name = "Info" ,
125- Aliases = new [ ] { "i" , "whowis " } ,
125+ Aliases = new [ ] { "i" , "whois " } ,
126126 Category = CommandCategory . Info ,
127127 IsConsoleSafe = true ,
128128 UsableByFrozenPlayers = true ,
@@ -743,63 +743,47 @@ private static void RanksHandler([NotNull] Player player, [NotNull] CommandReade
743743
744744 #endregion
745745 #region WhoIs
746- static readonly CommandDescriptor CdWhoIs = new CommandDescriptor
746+ static readonly CommandDescriptor CdWhoNick = new CommandDescriptor
747747 {
748- Name = "WhoIs " ,
748+ Name = "WhoNick " ,
749749 Aliases = new [ ] { "realname" } ,
750750 Category = CommandCategory . New | CommandCategory . Info ,
751751 Permissions = new [ ] { Permission . ViewOthersInfo } ,
752752 IsConsoleSafe = true ,
753753 UsableByFrozenPlayers = true ,
754- Usage = "/WhoIs [DisplayedName]" ,
754+ Usage = "/WhoNick [DisplayedName]" ,
755755 Help = "Prints a list of players using the specified displayed name." ,
756- Handler = WhoIsHandler
756+ Handler = WhoNickHandler
757757 } ;
758758
759- static void WhoIsHandler ( Player player , CommandReader cmd )
760- {
761- string TargetDisplayedName = cmd . Next ( ) ;
762- if ( TargetDisplayedName == null )
763- {
764- CdWhoIs . PrintUsage ( player ) ;
759+ static void WhoNickHandler ( Player player , CommandReader cmd ) {
760+ string target = cmd . NextAll ( ) ;
761+ if ( String . IsNullOrEmpty ( target ) ) {
762+ CdWhoNick . PrintUsage ( player ) ;
765763 return ;
766764 }
767- string whoislist = "" ;
765+ target = Color . StripColors ( target , false ) ;
766+
768767 //string offsetstring = cmd.Next();
769768 //int offset = 0;
770769 //if (offsetstring != null) {
771770 //Int32.TryParse(offsetstring, out offset);
772771 //}
773772
774- List < PlayerInfo > Results = new List < PlayerInfo > ( ) ;
775- PlayerInfo [ ] CachedList = PlayerDB . PlayerInfoList ;
776- foreach ( PlayerInfo playerinfo in CachedList ) {
777- if ( playerinfo . DisplayedName == null ) {
778- if ( Color . StripColors ( playerinfo . Name , false ) . CaselessEquals ( Color . StripColors ( TargetDisplayedName , false ) ) )
779- Results . Add ( playerinfo ) ;
780- } else {
781- if ( Color . StripColors ( playerinfo . DisplayedName , false ) . CaselessEquals ( Color . StripColors ( TargetDisplayedName , false ) ) )
782- Results . Add ( playerinfo ) ;
783- }
773+ List < PlayerInfo > matches = new List < PlayerInfo > ( ) ;
774+ PlayerInfo [ ] allPlayers = PlayerDB . PlayerInfoList ;
775+ foreach ( PlayerInfo pl in allPlayers ) {
776+ string nick = pl . DisplayedName == null ? pl . Name : pl . DisplayedName ;
777+ if ( Color . StripColors ( nick , false ) . CaselessEquals ( target ) ) matches . Add ( pl ) ;
784778 }
785779
786- if ( Results . Count <= 0 )
787- {
788- player . Message ( "No players have the displayed name \" " + TargetDisplayedName + "\" " ) ;
789- }
790- if ( Results . Count == 1 )
791- {
792- player . Message ( "{0} &Shas the displayed name \" " + TargetDisplayedName + "\" " , Results . ToArray ( ) [ 0 ] . Rank . Color + Results . ToArray ( ) [ 0 ] . Name ) ;
793- }
794- if ( Results . Count > 1 )
795- {
796- foreach ( PlayerInfo thisplayer in Results )
797- {
798- whoislist += thisplayer . Rank . Color + thisplayer . Name + ", " ;
799- }
800- whoislist = whoislist . Remove ( whoislist . Length - 2 ) ;
801- whoislist += "." ;
802- player . Message ( "The following players have the displayed name \" " + TargetDisplayedName + "\" &S: {0}" , whoislist ) ;
780+ if ( matches . Count == 0 ) {
781+ player . Message ( "No players have the displayed name \" " + target + "\" " ) ;
782+ } else if ( matches . Count == 1 ) {
783+ player . Message ( "{0} &Shas the displayed name \" " + target + "\" " , matches [ 0 ] . Rank . Color + matches [ 0 ] . Name ) ;
784+ } else {
785+ string all = matches . JoinToString ( pl => pl . Rank . Color + pl . Name ) ;
786+ player . Message ( "The following players have the displayed name \" " + target + "\" &S: {0}" , all ) ;
803787 }
804788 }
805789 #endregion
0 commit comments