本文整理汇总了C#中fCraft.Player.GetClassyName方法的典型用法代码示例。如果您正苦于以下问题:C# Player.GetClassyName方法的具体用法?C# Player.GetClassyName怎么用?C# Player.GetClassyName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.GetClassyName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StaffChat
internal static void StaffChat( Player player, Command cmd ) {
if( player.Info.IsMuted ) {
player.MutedMessage();
return;
}
if( DateTime.UtcNow < player.Info.MutedUntil ) {
player.Message( "You are muted for another {0:0} seconds.",
player.Info.MutedUntil.Subtract( DateTime.UtcNow ).TotalSeconds );
return;
}
Player[] plist = Server.PlayerList;
if( plist.Length > 0 ) player.Info.LinesWritten++;
string message = cmd.NextAll();
if( message != null && message.Trim().Length > 0 ) {
message = message.Trim();
if( player.Can( Permission.UseColorCodes ) && message.Contains( "%" ) ) {
message = Color.ReplacePercentCodes( message );
}
for( int i = 0; i < plist.Length; i++ ) {
if( (plist[i].Can( Permission.ReadStaffChat ) || plist[i] == player) && !plist[i].IsIgnoring( player.Info ) ) {
plist[i].Message( "{0}(staff){1}{0}: {2}", Color.PM, player.GetClassyName(), message );
}
}
}
}
示例2: Spectate
public bool Spectate( Player target ) {
if( target == null ) throw new ArgumentNullException( "target" );
if( target == this ) throw new ArgumentException( "Cannot spectate self.", "target" );
Message( "Now spectating {0}&S. Type &H/unspec&S to stop.", target.GetClassyName() );
return (Interlocked.Exchange<Player>( ref Session.SpectatedPlayer, target ) == null);
}
示例3: WorldLoad
internal static void WorldLoad( Player player, Command cmd ) {
string fileName = cmd.Next();
string worldName = cmd.Next();
if( worldName == null && player.World == null ) {
player.Message( "When using /wload from console, you must specify the world name." );
return;
}
if( fileName == null ) {
// No params given at all
cdWorldLoad.PrintUsage( player );
return;
}
// Check if path contains missing drives or invalid characters
if( !Paths.IsValidPath( fileName ) ) {
player.Message( "Invalid filename or path." );
return;
}
player.MessageNow( "Looking for \"{0}\"...", fileName );
// Look for the file
string sourceFullFileName = Path.Combine( Paths.MapPath, fileName );
if( !File.Exists( sourceFullFileName ) && !Directory.Exists( sourceFullFileName ) ) {
if( File.Exists( sourceFullFileName + ".fcm" ) ) {
// Try with extension added
fileName += ".fcm";
sourceFullFileName += ".fcm";
} else if( MonoCompat.IsCaseSensitive ) {
try {
// If we're on a case-sensitive OS, try case-insensitive search
FileInfo[] candidates = Paths.FindFiles( sourceFullFileName + ".fcm" );
if( candidates.Length == 0 ) {
candidates = Paths.FindFiles( sourceFullFileName );
}
if( candidates.Length == 0 ) {
player.Message( "File/directory not found: {0}", fileName );
} else if( candidates.Length == 1 ) {
player.Message( "Filenames are case-sensitive! Did you mean to load \"{0}\"?", candidates[0].Name );
} else {
player.Message( "Filenames are case-sensitive! Did you mean to load one of these: {0}",
String.Join( ", ", candidates.Select( c => c.Name ).ToArray() ) );
}
} catch( DirectoryNotFoundException ex ) {
player.Message( ex.Message );
}
return;
} else {
// Nothing found!
player.Message( "File/directory not found: {0}", fileName );
return;
}
}
// Make sure that the given file is within the map directory
if( !Paths.Contains( Paths.MapPath, sourceFullFileName ) ) {
player.UnsafePathMessage();
return;
}
// Loading map into current world
if( worldName == null ) {
if( !cmd.IsConfirmed ) {
player.AskForConfirmation( cmd, "About to replace THIS MAP with \"{0}\".", fileName );
return;
}
Map map;
try {
map = MapUtility.Load( sourceFullFileName );
} catch( Exception ex ) {
player.MessageNow( "Could not load specified file: {0}: {1}", ex.GetType().Name, ex.Message );
return;
}
// Loading to current world
player.World.ChangeMap( map );
player.World.SendToAllExcept( "{0}&S loaded a new map for this world.", player,
player.GetClassyName() );
player.MessageNow( "New map loaded for the world {0}", player.World.GetClassyName() );
Logger.Log( "{0} loaded new map for world \"{1}\" from {2}", LogType.UserActivity,
player.Name, player.World.Name, fileName );
} else {
// Loading to some other (or new) world
if( !World.IsValidName( worldName ) ) {
player.MessageNow( "Invalid world name: \"{0}\".", worldName );
return;
}
lock( WorldManager.WorldListLock ) {
//.........这里部分代码省略.........
示例4: WorldBuild
internal static void WorldBuild( Player player, Command cmd ) {
string worldName = cmd.Next();
// Print information about the current world
if( worldName == null ) {
if( player == Player.Console ) {
player.Message( "When calling /wbuild from console, you must specify a world name." );
} else {
player.World.BuildSecurity.PrintDescription( player, player.World, "world", "modified" );
}
return;
}
// Find a world by name
World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
if( world == null ) return;
string name = cmd.Next();
if( name == null ) {
world.BuildSecurity.PrintDescription( player, world, "world", "modified" );
return;
}
bool changesWereMade = false;
do {
if( name.Length < 2 ) continue;
// Whitelisting individuals
if( name.StartsWith( "+" ) ) {
PlayerInfo info;
if( !PlayerDB.FindPlayerInfo( name.Substring( 1 ), out info ) ) {
player.Message( "More than one player found matching \"{0}\"", name.Substring( 1 ) );
continue;
} else if( info == null ) {
player.NoPlayerMessage( name.Substring( 1 ) );
continue;
}
// prevent players from whitelisting themselves to bypass protection
if( player.Info == info && !player.Info.Rank.AllowSecurityCircumvention ) {
switch( world.BuildSecurity.CheckDetailed( player.Info ) ) {
case SecurityCheckResult.RankTooLow:
player.Message( "&WYou must be {0}&W+ to add yourself to the build whitelist of {0}",
world.BuildSecurity.MinRank.GetClassyName(),
world.GetClassyName() );
continue;
// TODO: RankTooHigh
case SecurityCheckResult.BlackListed:
player.Message( "&WYou cannot remove yourself from the build blacklist of {0}",
world.GetClassyName() );
continue;
}
}
if( world.BuildSecurity.CheckDetailed( info ) == SecurityCheckResult.Allowed ) {
player.Message( "{0}&S is already allowed to build in {1}&S (by rank)",
info.GetClassyName(), world.GetClassyName() );
continue;
}
Player target = Server.FindPlayerExact( info );
if( target == player ) target = null; // to avoid duplicate messages
switch( world.BuildSecurity.Include( info ) ) {
case PermissionOverride.Deny:
if( world.BuildSecurity.Check( info ) ) {
player.Message( "{0}&S is no longer barred from building in {1}",
info.GetClassyName(), world.GetClassyName() );
if( target != null ) {
target.Message( "You can now build in world {0}&S (removed from blacklist by {1}&S).",
world.GetClassyName(), player.GetClassyName() );
}
} else {
player.Message( "{0}&S was removed from the build blacklist of {1}&S. " +
"Player is still NOT allowed to build (by rank).",
info.GetClassyName(), world.GetClassyName() );
if( target != null ) {
target.Message( "You were removed from the build blacklist of world {0}&S by {1}&S. " +
"You are still NOT allowed to build (by rank).",
player.GetClassyName(), world.GetClassyName() );
}
}
Logger.Log( "{0} removed {1} from the build blacklist of {2}", LogType.UserActivity,
player.Name, info.Name, world.Name );
changesWereMade = true;
break;
case PermissionOverride.None:
player.Message( "{0}&S is now allowed to build in {1}",
info.GetClassyName(), world.GetClassyName() );
if( target != null ) {
target.Message( "You can now build in world {0}&S (whitelisted by {1}&S).",
world.GetClassyName(), player.GetClassyName() );
}
Logger.Log( "{0} added {1} to the build whitelist on world {2}", LogType.UserActivity,
player.Name, info.Name, world.Name );
changesWereMade = true;
break;
case PermissionOverride.Allow:
//.........这里部分代码省略.........
示例5: WorldMain
internal static void WorldMain( Player player, Command cmd ) {
string worldName = cmd.Next();
if( worldName == null ) {
player.Message( "Main world is {0}", WorldManager.MainWorld.GetClassyName() );
return;
}
World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
if( world == null ) {
return;
} else if( world == WorldManager.MainWorld ) {
player.Message( "World {0}&S is already set as main.", world.GetClassyName() );
} else if( !player.Info.Rank.AllowSecurityCircumvention && !player.CanJoin( world ) ) {
// Prevent players from exploiting /wmain to gain access to restricted maps
switch( world.AccessSecurity.CheckDetailed( player.Info ) ) {
case SecurityCheckResult.RankTooHigh:
case SecurityCheckResult.RankTooLow:
player.Message( "You are not allowed to set {0}&S as the main world (by rank).", world.GetClassyName() );
return;
case SecurityCheckResult.BlackListed:
player.Message( "You are not allowed to set {0}&S as the main world (blacklisted).", world.GetClassyName() );
return;
}
} else {
if( world.AccessSecurity.HasRestrictions() ) {
world.AccessSecurity.Reset();
player.Message( "The main world cannot have access restrictions. " +
"All access restrictions were removed from world {0}",
world.GetClassyName() );
}
if( !world.SetMainWorld() ) {
player.Message( "Main world was not changed." );
return;
}
WorldManager.SaveWorldList();
Server.SendToAll( "{0}&S set {1}&S to be the main world.",
player.GetClassyName(), world.GetClassyName() );
Logger.Log( "{0} set {1} to be the main world.", LogType.UserActivity,
player.Name, world.Name );
}
}
示例6: WorldUnload
internal static void WorldUnload( Player player, Command cmd ) {
string worldName = cmd.Next();
if( worldName == null ) {
cdWorldUnload.PrintUsage( player );
return;
}
World world = WorldManager.FindWorldOrPrintMatches( player, worldName );
if( world == null ) return;
try {
WorldManager.RemoveWorld( world );
} catch( WorldOpException ex ) {
switch( ex.ErrorCode ) {
case WorldOpExceptionCode.CannotDoThatToMainWorld:
player.MessageNow( "&WWorld {0}&W is set as the main world. " +
"Assign a new main world before deleting this one.",
world.GetClassyName() );
return;
case WorldOpExceptionCode.WorldNotFound:
player.MessageNow( "&WWorld {0}&W is already unloaded.",
world.GetClassyName() );
return;
default:
player.MessageNow( "&WUnexpected error occured while unloading world {0}&W: {1}",
world.GetClassyName(), ex.GetType().Name );
Logger.Log( "WorldCommands.WorldUnload: Unexpected error while unloading world {0}: {1}",
LogType.Error, world.Name, ex );
return;
}
}
WorldManager.SaveWorldList();
Server.SendToAllExcept( "{0}&S removed {1}&S from the world list.", player,
player.GetClassyName(), world.GetClassyName() );
player.Message( "Removed {0}&S from the world list. You can now delete the map file ({1}.fcm) manually.",
world.GetClassyName(), world.Name );
Logger.Log( "{0} removed \"{1}\" from the world list.", LogType.UserActivity,
player.Name, worldName );
Server.RequestGC();
}
示例7: WorldRename
internal static void WorldRename( Player player, Command cmd ) {
string oldName = cmd.Next();
string newName = cmd.Next();
if( oldName == null || newName == null ) {
cdWorldRename.PrintUsage( player );
return;
}
World oldWorld = WorldManager.FindWorldOrPrintMatches( player, oldName );
if( oldWorld == null ) return;
oldName = oldWorld.Name;
if( !cmd.IsConfirmed && File.Exists( Path.Combine( Paths.MapPath, newName + ".fcm" ) ) ) {
player.AskForConfirmation( cmd, "Renaming this world will overwrite an existing map file \"{0}.fcm\".", newName );
return;
}
try {
WorldManager.RenameWorld( oldWorld, newName, true );
} catch( WorldOpException ex ) {
switch( ex.ErrorCode ) {
case WorldOpExceptionCode.NoChangeNeeded:
player.MessageNow( "Rename: World is already named \"{0}\"", oldName );
return;
case WorldOpExceptionCode.DuplicateWorldName:
player.MessageNow( "Rename: Another world named \"{0}\" already exists.", newName );
return;
case WorldOpExceptionCode.InvalidWorldName:
player.MessageNow( "Rename: Invalid world name: \"{0}\"", newName );
return;
case WorldOpExceptionCode.MapMoveError:
player.MessageNow( "Rename: World \"{0}\" was renamed to \"{1}\", but the map file could not be moved due to an error: {2}",
oldName, newName, ex.InnerException );
return;
default:
player.MessageNow( "Unexpected error occured while renaming world \"{0}\"", oldName );
Logger.Log( "WorldCommands.Rename: Unexpected error while renaming world {0} to {1}: {2}",
LogType.Error, oldWorld.Name, newName, ex );
return;
}
}
WorldManager.SaveWorldList();
Logger.Log( "{0} renamed the world \"{1}\" to \"{2}\".", LogType.UserActivity,
player.Name, oldName, newName );
Server.SendToAll( "{0}&S renamed the world \"{1}\" to \"{2}\"",
player.GetClassyName(), oldName, newName );
}
示例8: Roll
internal static void Roll( Player player, Command cmd ) {
if( player.Info.IsMuted ) {
player.MutedMessage();
return;
}
Random rand = new Random();
int min = 1, max = 100, t1;
if( cmd.NextInt( out t1 ) ) {
int t2;
if( cmd.NextInt( out t2 ) ) {
if( t2 < t1 ) {
min = t2;
max = t1;
} else {
min = t1;
max = t2;
}
} else if( t1 >= 1 ) {
max = t1;
}
}
int num = rand.Next( min, max + 1 );
Server.SendToAll( "{0}{1} rolled {2} ({3}...{4})",
player.GetClassyName(), Color.Silver, num, min, max );
}
示例9: LoginSequence
//.........这里部分代码省略.........
Logger.Log( "{0} IP matched previous records for that name. Player was allowed in.", LogType.SuspiciousActivity,
standardMessage );
break;
}
} else {
switch( nameVerificationMode ) {
case NameVerificationMode.Always:
case NameVerificationMode.Balanced:
Player.Info.ProcessFailedLogin( this );
Logger.Log( "{0} IP did not match. Player was kicked.", LogType.SuspiciousActivity,
standardMessage );
KickNow( "Could not verify player name!", LeaveReason.UnverifiedName );
return false;
case NameVerificationMode.Never:
Logger.Log( "{0} IP did not match. " +
"Player was allowed in anyway because VerifyNames is set to Never.", LogType.SuspiciousActivity,
standardMessage );
Player.Message( "&WYour name could not be verified." );
showVerifyNamesWarning = true;
break;
}
}
}
// Check if player is banned
if( Player.Info.Banned ) {
Player.Info.ProcessFailedLogin( this );
Logger.Log( "Banned player {0} tried to log in from {1}", LogType.SuspiciousActivity,
Player.Name, IP );
if( ConfigKey.ShowBannedConnectionMessages.GetBool() ) {
Server.SendToAllWhoCan( "&SBanned player {0}&S tried to log in from {1}", null, Permission.ViewPlayerIPs,
Player.GetClassyName(), IP );
Server.SendToAllWhoCant( "&SBanned player {0}&S tried to log in.", null, Permission.ViewPlayerIPs,
Player.GetClassyName() );
}
string bannedMessage = String.Format( "Banned {0} ago by {1}: {2}",
Player.Info.TimeSinceBan.ToMiniString(),
Player.Info.BannedBy,
Player.Info.BanReason );
KickNow( bannedMessage, LeaveReason.LoginFailed );
return false;
}
// Check if player's IP is banned
IPBanInfo ipBanInfo = IPBanList.Get( IP );
if( ipBanInfo != null ) {
Player.Info.ProcessFailedLogin( this );
ipBanInfo.ProcessAttempt( Player );
if( ConfigKey.ShowBannedConnectionMessages.GetBool() ) {
Server.SendToAll( "{0}&S tried to log in from a banned IP.", Player.GetClassyName() );
}
Logger.Log( "{0} tried to log in from a banned IP.", LogType.SuspiciousActivity,
Player.Name );
string bannedMessage = String.Format( "IP-banned {0} ago by {1}: {2}",
DateTime.UtcNow.Subtract( ipBanInfo.BanDate ).ToMiniString(),
ipBanInfo.BannedBy,
ipBanInfo.BanReason );
KickNow( bannedMessage, LeaveReason.LoginFailed );
return false;
}
// Check if max number of connections is reached for IP
示例10: Shutdown
static void Shutdown( Player player, Command cmd ) {
int delay;
if( !cmd.NextInt( out delay ) ) {
delay = 5;
cmd.Rewind();
}
string reason = cmd.NextAll();
if( reason.Equals( "abort", StringComparison.OrdinalIgnoreCase ) ) {
if( Server.CancelShutdown() ) {
Logger.Log( "Shutdown aborted by {0}.", LogType.UserActivity, player.Name );
Server.SendToAll( "&WShutdown aborted by {0}", player.GetClassyName() );
} else {
player.MessageNow( "Cannot abort shutdown - too late." );
}
return;
}
Server.SendToAll( "&WServer shutting down in {0} seconds.", delay );
if( String.IsNullOrEmpty( reason ) ) {
Logger.Log( "{0} shut down the server ({1} second delay).", LogType.UserActivity,
player.Name, delay );
ShutdownParams sp = new ShutdownParams( ShutdownReason.ShuttingDown, delay, true, false );
Server.Shutdown( sp, false );
} else {
Server.SendToAll( "&WShutdown reason: {0}", reason );
Logger.Log( "{0} shut down the server ({1} second delay). Reason: {2}", LogType.UserActivity,
player.Name, delay, reason );
ShutdownParams sp = new ShutdownParams( ShutdownReason.ShuttingDown, delay, true, false, reason, player );
Server.Shutdown( sp, false );
}
}
示例11: Unlock
public bool Unlock( Player player ) {
if( player == null ) throw new ArgumentNullException( "player" );
lock( lockLock ) {
if( IsLocked ) {
UnlockedBy = player.Name;
UnlockedDate = DateTime.UtcNow;
IsLocked = false;
SendToAll( "&WMap was unlocked by {0}", player.GetClassyName() );
Logger.Log( "World \"{0}\" was unlocked by {1}", LogType.UserActivity,
Name, player.Name );
return true;
} else {
return false;
}
}
}
示例12: Lock
public bool Lock( Player player ) {
if( player == null ) throw new ArgumentNullException( "player" );
lock( lockLock ) {
if( IsLocked ) {
return false;
} else {
LockedBy = player.Name;
LockedDate = DateTime.UtcNow;
IsLocked = true;
if( Map != null ) Map.ClearUpdateQueue();
SendToAll( "&WMap was locked by {0}", player.GetClassyName() );
Logger.Log( "World {0} was locked by {1}", LogType.UserActivity,
Name, player.Name );
return true;
}
}
}
示例13: AcceptPlayer
public Map AcceptPlayer( Player player, bool announce ) {
if( player == null ) throw new ArgumentNullException( "player" );
lock( WorldLock ) {
if( IsFull ) {
return null;
}
if( players.ContainsKey( player.Name.ToLower() ) ) {
Logger.Log( "This world already contains the player by name ({0}). " +
"Some sort of state corruption must have occured.", LogType.Error,
player.Name );
players.Remove( player.Name.ToLower() );
}
players.Add( player.Name.ToLower(), player );
// load the map, if it's not yet loaded
PendingUnload = false;
if( Map == null ) {
LoadMap();
}
if( ConfigKey.BackupOnJoin.GetBool() ) {
string backupFileName = String.Format( "{0}_{1:yyyy-MM-dd_HH-mm}_{2}.fcm",
Name, DateTime.Now, player.Name ); // localized
Map.SaveBackup( Path.Combine( Paths.MapPath, GetMapName() ),
Path.Combine( Paths.BackupPath, backupFileName ),
true );
}
AddPlayerForPatrol( player );
UpdatePlayerList();
if( announce && ConfigKey.ShowJoinedWorldMessages.GetBool() ) {
string message = String.Format( "&SPlayer {0}&S joined {1}", player.GetClassyName(), GetClassyName() );
foreach( Packet packet in PacketWriter.MakeWrappedMessage( ">", message, false ) ) {
Server.SendToSeeing( packet, player );
}
}
Logger.Log( "Player {0} joined world {1}.", LogType.UserActivity,
player.Name, Name );
if( OnPlayerJoined != null ) OnPlayerJoined( player, this );
if( IsLocked ) {
player.Message( "&WThis map is currently locked (read-only)." );
}
if( player.IsHidden ) {
player.Message( "Reminder: You are still hidden." );
}
return Map;
}
}