private static void TitleHandler( Player player, Command cmd )
{
string targetName = cmd.Next();
string titleName = cmd.NextAll();
if ( string.IsNullOrEmpty( targetName ) ) {
CdTitle.PrintUsage( player );
return;
}
PlayerInfo info = PlayerDB.FindPlayerInfoOrPrintMatches( player, targetName );
if ( info == null )
return;
string oldTitle = info.TitleName;
if ( titleName.Length == 0 )
titleName = null;
if ( titleName == info.TitleName ) {
if ( titleName == null ) {
player.Message( "Title: Title for {0} is not set.",
info.Name );
} else {
player.Message( "Title: Title for {0} is already set to \"{1}&S\"",
info.Name,
titleName );
}
return;
}
//check the title, is it a title?
if ( titleName != null ) {
string StripT = Color.StripColors( titleName );
if ( !StripT.StartsWith( "[" ) && !StripT.EndsWith( "]" ) ) {
//notify player, confirm with /ok TODO
//titleName = info.Rank.Color + "[" + titleName + info.Rank.Color + "]";
}
}
info.TitleName = titleName;
if ( oldTitle == null ) {
player.Message( "Title: Title for {0} set to \"{1}&S\"",
info.Name,
titleName );
} else if ( titleName == null ) {
player.Message( "Title: Title for {0} was reset (was \"{1}&S\")",
info.Name,
oldTitle );
} else {
player.Message( "Title: Title for {0} changed from \"{1}&S\" to \"{2}&S\"",
info.Name,
oldTitle,
titleName );
}
}