本文整理汇总了C#中fCraft.Player.MessageNow方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessageNow方法的具体用法?C# Player.MessageNow怎么用?C# Player.MessageNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.MessageNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplyHandler
static void ReplyHandler( Player player, CommandReader cmd ) {
string messageText = cmd.NextAll();
if( messageText.Length == 0 ) {
player.Message( "Reply: No message to send!" );
return;
}
string targetName = player.lastPrivateMessageSender;
if( targetName != null ) {
Player targetPlayer = Server.FindPlayerExact( player,
targetName,
SearchOptions.IncludeHidden );
if( targetPlayer != null ) {
if( player.CanSee( targetPlayer ) ) {
if( targetPlayer.IsDeaf ) {
player.Message( "Cannot PM {0}&S: they are currently deaf.", targetPlayer.ClassyName );
} else if( targetPlayer.IsIgnoring( player.Info ) ) {
player.Message( "&WCannot PM {0}&W: you are ignored.", targetPlayer.ClassyName );
} else {
Chat.SendPM( player, targetPlayer, messageText );
player.MessageNow( "&Pto {0}: {1}", targetPlayer.Name, messageText );
}
} else {
player.Message( "Reply: Cannot send message; player {0}&S is offline.",
PlayerDB.FindExactClassyName( targetName ) );
if( targetPlayer.CanHear( player ) ) {
Chat.SendPM( player, targetPlayer, messageText );
player.Info.DecrementMessageWritten();
}
}
} else {
player.Message( "Reply: Cannot send message; player {0}&S is offline.",
PlayerDB.FindExactClassyName( targetName ) );
}
} else {
player.Message( "Reply: You have not sent any messages yet." );
}
}
示例2: WorldRenameHandler
static void WorldRenameHandler(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 (!World.IsValidName(newName))
{
player.MessageInvalidWorldName(newName);
return;
}
World newWorld = WorldManager.FindWorldExact(newName);
if (!cmd.IsConfirmed && newWorld != null && newWorld != oldWorld)
{
player.Confirm(cmd, "A world named {0}&S already exists. Replace it?", newWorld.ClassyName);
return;
}
if (!cmd.IsConfirmed && File.Exists(Path.Combine(Paths.MapPath, newName + ".fcm")))
{
player.Confirm(cmd, "Renaming this world will overwrite an existing map file \"{0}.fcm\".", newName);
return;
}
try
{
WorldManager.RenameWorld(oldWorld, newName, true, true);
}
catch (WorldOpException ex)
{
switch (ex.ErrorCode)
{
case WorldOpExceptionCode.NoChangeNeeded:
player.MessageNow("WRename: World is already named \"{0}\"", oldName);
return;
case WorldOpExceptionCode.DuplicateWorldName:
player.MessageNow("WRename: Another world named \"{0}\" already exists.", newName);
return;
case WorldOpExceptionCode.InvalidWorldName:
player.MessageNow("WRename: Invalid world name: \"{0}\"", newName);
return;
case WorldOpExceptionCode.MapMoveError:
player.MessageNow("WRename: 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("&WWRename: Unexpected error renaming world \"{0}\": {1}", oldName, ex.Message);
Logger.Log(LogType.Error,
"WorldCommands.Rename: Unexpected error while renaming world {0} to {1}: {2}",
oldWorld.Name, newName, ex);
return;
}
}
player.LastUsedWorldName = newName;
WorldManager.SaveWorldList();
Logger.Log(LogType.UserActivity,
"{0} renamed the world \"{1}\" to \"{2}\".",
player.Name, oldName, newName);
Server.Message("{0}&S renamed the world \"{1}\" to \"{2}\"",
player.ClassyName, oldName, newName);
}
示例3: PruneDBHandler
static void PruneDBHandler( Player player, Command cmd )
{
if( !cmd.IsConfirmed ) {
player.MessageNow( "PruneDB: Finding inactive players..." );
int inactivePlayers = PlayerDB.CountInactivePlayers();
if( inactivePlayers == 0 ) {
player.Message( "PruneDB: No inactive players found." );
} else {
player.Confirm( cmd, "PruneDB: Erase {0} records of inactive players?",
inactivePlayers );
}
} else {
Scheduler.NewBackgroundTask( PruneDBTask, player ).RunOnce();
}
}
示例4: CopyCallback
static void CopyCallback( Player player, Vector3I[] marks, object tag ) {
int sx = Math.Min( marks[0].X, marks[1].X );
int ex = Math.Max( marks[0].X, marks[1].X );
int sy = Math.Min( marks[0].Y, marks[1].Y );
int ey = Math.Max( marks[0].Y, marks[1].Y );
int sz = Math.Min( marks[0].Z, marks[1].Z );
int ez = Math.Max( marks[0].Z, marks[1].Z );
BoundingBox bounds = new BoundingBox( sx, sy, sz, ex, ey, ez );
int volume = bounds.Volume;
if( !player.CanDraw( volume ) ) {
player.MessageNow( "You are only allowed to run commands that affect up to {0} blocks. This one would affect {1} blocks.",
player.Info.Rank.DrawLimit, volume );
return;
}
// remember dimensions and orientation
CopyState copyInfo = new CopyState( marks[0], marks[1] );
Map map = player.WorldMap;
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
for( int x = sx; x <= ex; x++ ) {
for( int y = sy; y <= ey; y++ ) {
for( int z = sz; z <= ez; z++ ) {
copyInfo.Blocks[x - sx, y - sy, z - sz] = map.GetBlock( x, y, z );
}
}
}
copyInfo.OriginWorld = playerWorld.Name;
copyInfo.CopyTime = DateTime.UtcNow;
player.SetCopyState( copyInfo );
player.MessageNow( "{0} blocks copied into slot #{1}, origin at {2} corner. You can now &H/Paste",
volume,
player.CopySlot + 1,
copyInfo.OriginCorner );
Logger.Log( LogType.UserActivity,
"{0} copied {1} blocks from world {2} (between {3} and {4}).",
player.Name, volume, playerWorld.Name,
bounds.MinVertex, bounds.MaxVertex );
}
示例5: RedoHandler
static void RedoHandler( Player player, CommandReader cmd ) {
if( cmd.HasNext ) {
CdRedo.PrintUsage( player );
return;
}
World playerWorld = player.World;
if( playerWorld == null ) PlayerOpException.ThrowNoWorld( player );
UndoState redoState = player.RedoPop();
if( redoState == null ) {
player.MessageNow( "There is currently nothing to redo." );
return;
}
string msg = "Redo: ";
if( redoState.Op != null && !redoState.Op.IsDone ) {
redoState.Op.Cancel();
msg += String.Format( "Cancelled {0} (was {1}% done). ",
redoState.Op.Description,
redoState.Op.PercentDone );
}
// no need to set player.drawingInProgress here because this is done on the user thread
Logger.Log( LogType.UserActivity,
"Player {0} initiated /Redo affecting {1} blocks (on world {2})",
player.Name,
redoState.Buffer.Count,
playerWorld.Name );
msg += String.Format( "Restoring {0} blocks. Type &H/Undo&S to reverse.",
redoState.Buffer.Count );
player.MessageNow( msg );
var op = new UndoDrawOperation( player, redoState, true );
op.Prepare( new Vector3I[0] );
op.Begin();
}
示例6: ReplaceHandlerInternal
static void ReplaceHandlerInternal( IBrush factory, Player player, CommandReader cmd ) {
CuboidDrawOperation op = new CuboidDrawOperation( player );
IBrushInstance brush = factory.MakeInstance( player, cmd, op );
if( brush == null ) return;
op.Brush = brush;
player.SelectionStart( 2, DrawOperationCallback, op, Permission.Draw );
player.MessageNow( "{0}: Click or &H/Mark&S 2 blocks.",
op.Brush.InstanceDescription );
}
示例7: UndoAreaNotHandler
static void UndoAreaNotHandler( Player player, CommandReader cmd ) {
BlockDBUndoArgs args = ParseBlockDBUndoParams( player, cmd, "UndoAreaNot", true );
if( args == null ) return;
player.SelectionStart( 2, UndoAreaSelectionCallback, args, CdUndoAreaNot.Permissions );
player.MessageNow( "UndoAreaNot: Click or &H/Mark&S 2 blocks." );
}
示例8: MarkHandler
static void MarkHandler( Player player, CommandReader cmd ) {
Map map = player.WorldMap;
int x, y, z;
Vector3I coords;
if( cmd.NextInt( out x ) && cmd.NextInt( out y ) && cmd.NextInt( out z ) ) {
if( cmd.HasNext ) {
CdMark.PrintUsage( player );
return;
}
coords = new Vector3I( x, y, z );
} else {
coords = player.Position.ToBlockCoords();
}
coords.X = Math.Min( map.Width - 1, Math.Max( 0, coords.X ) );
coords.Y = Math.Min( map.Length - 1, Math.Max( 0, coords.Y ) );
coords.Z = Math.Min( map.Height - 1, Math.Max( 0, coords.Z ) );
if( player.SelectionMarksExpected > 0 ) {
player.SelectionAddMark( coords, true, true );
} else {
player.MessageNow( "Cannot mark - no selection in progress." );
}
}
示例9: PasteXHandler
static void PasteXHandler( Player player, Command cmd )
{
PasteDrawOperation op = new PasteDrawOperation( player, false );
if( !op.ReadParams( cmd ) ) return;
player.SelectionStart( 2, DrawOperationCallback, op, Permission.Draw, Permission.CopyAndPaste );
player.MessageNow( "{0}: Click 2 blocks or use &H/Mark&S to make a selection.",
op.Description );
}
示例10: PasteNotHandler
static void PasteNotHandler( Player player, Command cmd )
{
QuickPasteDrawOperation op = new QuickPasteDrawOperation( player, true );
if( !op.ReadParams( cmd ) ) return;
player.SelectionStart( 1, DrawOperationCallback, op, Permission.Draw, Permission.CopyAndPaste );
player.MessageNow( "{0}: Click a block or use &H/Mark&S to begin pasting.",
op.Description );
}
示例11: ZoneMarkHandler
static void ZoneMarkHandler( Player player, Command cmd )
{
if( player.SelectionMarksExpected == 0 ) {
player.MessageNow( "Cannot use ZMark - no selection in progress." );
} else if( player.SelectionMarksExpected == 2 ) {
string zoneName = cmd.Next();
if( zoneName == null ) {
CdZoneMark.PrintUsage( player );
return;
}
Zone zone = player.WorldMap.Zones.Find( zoneName );
if( zone == null ) {
player.MessageNoZone( zoneName );
return;
}
player.SelectionResetMarks();
player.SelectionAddMark( zone.Bounds.MinVertex, false );
player.SelectionAddMark( zone.Bounds.MaxVertex, true );
} else {
player.MessageNow( "ZMark can only be used for 2-block selection." );
}
}
示例12: DeafenHandler
static void DeafenHandler( Player player, Command cmd ) {
if( cmd.HasNext ) {
CdDeafen.PrintUsage( player );
return;
}
if( !player.IsDeaf ) {
for( int i = 0; i < LinesToClear; i++ ) {
player.MessageNow( "" );
}
player.MessageNow( "Deafened mode: ON" );
player.MessageNow( "You will not see ANY messages until you type &H/Deafen&S again." );
player.IsDeaf = true;
} else {
player.IsDeaf = false;
player.MessageNow( "Deafened mode: OFF" );
}
}
示例13: UnignoreHandler
static void UnignoreHandler( Player player, Command cmd ) {
string name = cmd.Next();
if( name != null ) {
if( cmd.HasNext ) {
CdUnignore.PrintUsage( player );
return;
}
PlayerInfo targetInfo = PlayerDB.FindPlayerInfoOrPrintMatches( player, name );
if( targetInfo == null ) return;
if( player.Unignore( targetInfo ) ) {
player.MessageNow( "You are no longer ignoring {0}", targetInfo.ClassyName );
} else {
player.MessageNow( "You are not currently ignoring {0}", targetInfo.ClassyName );
}
} else {
PlayerInfo[] ignoreList = player.IgnoreList;
if( ignoreList.Length > 0 ) {
player.MessageNow( "Ignored players: {0}", ignoreList.JoinToClassyString() );
} else {
player.MessageNow( "You are not currently ignoring anyone." );
}
return;
}
}
示例14: WorldUnloadHandler
static void WorldUnloadHandler(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.ClassyName);
return;
case WorldOpExceptionCode.WorldNotFound:
player.MessageNow("&WWorld {0}&W is already unloaded.",
world.ClassyName);
return;
default:
player.MessageNow("&WUnexpected error occured while unloading world {0}&W: {1}",
world.ClassyName, ex.GetType().Name);
Logger.Log(LogType.Error,
"WorldCommands.WorldUnload: Unexpected error while unloading world {0}: {1}",
world.Name, ex);
return;
}
}
WorldManager.SaveWorldList();
Server.Message(player,
"{0}&S removed {1}&S from the world list.",
player.ClassyName, world.ClassyName);
player.Message("Removed {0}&S from the world list. You can now delete the map file ({1}.fcm) manually.",
world.ClassyName, world.Name);
Logger.Log(LogType.UserActivity,
"{0} removed \"{1}\" from the world list.",
player.Name, worldName);
Server.RequestGC();
}
示例15: WorldSaveHandler
static void WorldSaveHandler(Player player, Command cmd)
{
string p1 = cmd.Next(), p2 = cmd.Next();
if (p1 == null)
{
CdWorldSave.PrintUsage(player);
return;
}
World world = player.World;
string fileName;
if (p2 == null)
{
fileName = p1;
if (world == null)
{
player.Message("When called from console, /wsave requires WorldName. See \"/Help save\" for details.");
return;
}
}
else
{
world = WorldManager.FindWorldOrPrintMatches(player, p1);
if (world == null) return;
fileName = p2;
}
// normalize the path
fileName = fileName.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
if (fileName.EndsWith("/") && fileName.EndsWith(@"\"))
{
fileName += world.Name + ".fcm";
}
else if (!fileName.ToLower().EndsWith(".fcm", StringComparison.OrdinalIgnoreCase))
{
fileName += ".fcm";
}
if (!Paths.IsValidPath(fileName))
{
player.Message("Invalid filename.");
return;
}
string fullFileName = Path.Combine(Paths.MapPath, fileName);
if (!Paths.Contains(Paths.MapPath, fullFileName))
{
player.MessageUnsafePath();
return;
}
// Ask for confirmation if overwriting
if (File.Exists(fullFileName))
{
FileInfo targetFile = new FileInfo(fullFileName);
FileInfo sourceFile = new FileInfo(world.MapFileName);
if (!targetFile.FullName.Equals(sourceFile.FullName, StringComparison.OrdinalIgnoreCase))
{
if (!cmd.IsConfirmed)
{
player.Confirm(cmd, "Target file \"{0}\" already exists, and will be overwritten.", targetFile.Name);
return;
}
}
}
// Create the target directory if it does not exist
string dirName = fullFileName.Substring(0, fullFileName.LastIndexOf(Path.DirectorySeparatorChar));
if (!Directory.Exists(dirName))
{
Directory.CreateDirectory(dirName);
}
player.MessageNow("Saving map to {0}", fileName);
const string mapSavingErrorMessage = "Map saving failed. See server logs for details.";
Map map = world.Map;
if (map == null)
{
if (File.Exists(world.MapFileName))
{
try
{
File.Copy(world.MapFileName, fullFileName, true);
}
catch (Exception ex)
{
Logger.Log(LogType.Error,
"WorldCommands.WorldSave: Error occured while trying to copy an unloaded map: {0}", ex);
player.Message(mapSavingErrorMessage);
}
}
else
{
Logger.Log(LogType.Error,
"WorldCommands.WorldSave: Map for world \"{0}\" is unloaded, and file does not exist.",
world.Name);
player.Message(mapSavingErrorMessage);
}
}
else if (map.Save(fullFileName))
{
//.........这里部分代码省略.........