本文整理汇总了C#中fCraft.Player.MessageInvalidWorldName方法的典型用法代码示例。如果您正苦于以下问题:C# Player.MessageInvalidWorldName方法的具体用法?C# Player.MessageInvalidWorldName怎么用?C# Player.MessageInvalidWorldName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.Player
的用法示例。
在下文中一共展示了Player.MessageInvalidWorldName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorldLoadHandler
static void WorldLoadHandler(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;
}
string fullFileName = WorldManager.FindMapFile(player, fileName);
if (fullFileName == null) return;
// Loading map into current world
if (worldName == null)
{
if (!cmd.IsConfirmed)
{
player.Confirm(cmd, "Replace THIS MAP with \"{0}\"?", fileName);
return;
}
Map map;
try
{
map = MapUtility.Load(fullFileName);
}
catch (Exception ex)
{
player.MessageNow("Could not load specified file: {0}: {1}", ex.GetType().Name, ex.Message);
return;
}
World world = player.World;
// Loading to current world
world.MapChangedBy = player.Name;
world.ChangeMap(map);
world.Players.Message(player, "{0}&S loaded a new map for this world.",
player.ClassyName);
player.MessageNow("New map loaded for the world {0}", world.ClassyName);
Logger.Log(LogType.UserActivity,
"{0} loaded new map for world \"{1}\" from {2}",
player.Name, world.Name, fileName);
}
else
{
// Loading to some other (or new) world
if (!World.IsValidName(worldName))
{
player.MessageInvalidWorldName(worldName);
return;
}
string buildRankName = cmd.Next();
string accessRankName = cmd.Next();
Rank buildRank = RankManager.DefaultBuildRank;
Rank accessRank = null;
if (buildRankName != null)
{
buildRank = RankManager.FindRank(buildRankName);
if (buildRank == null)
{
player.MessageNoRank(buildRankName);
return;
}
if (accessRankName != null)
{
accessRank = RankManager.FindRank(accessRankName);
if (accessRank == null)
{
player.MessageNoRank(accessRankName);
return;
}
}
}
// Retype world name, if needed
if (worldName == "-")
{
if (player.LastUsedWorldName != null)
{
worldName = player.LastUsedWorldName;
}
else
{
player.Message("Cannot repeat world name: you haven't used any names yet.");
return;
}
}
//.........这里部分代码省略.........
示例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: PortalCreateCallback
static void PortalCreateCallback(Player player, Vector3I[] marks, object tag)
{
try
{
World world = WorldManager.FindWorldExact(player.PortalWorld);
if (world != null)
{
DrawOperation op = (DrawOperation)tag;
if (!op.Prepare(marks)) return;
if (!player.CanDraw(op.BlocksTotalEstimate))
{
player.MessageNow("You are only allowed to run draw commands that affect up to {0} blocks. This one would affect {1} blocks.",
player.Info.Rank.DrawLimit,
op.Bounds.Volume);
op.Cancel();
return;
}
int Xmin = Math.Min(marks[0].X, marks[1].X);
int Xmax = Math.Max(marks[0].X, marks[1].X);
int Ymin = Math.Min(marks[0].Y, marks[1].Y);
int Ymax = Math.Max(marks[0].Y, marks[1].Y);
int Zmin = Math.Min(marks[0].Z, marks[1].Z);
int Zmax = Math.Max(marks[0].Z, marks[1].Z);
for (int x = Xmin; x <= Xmax; x++)
{
for (int y = Ymin; y <= Ymax; y++)
{
for (int z = Zmin; z <= Zmax; z++)
{
if (PortalHandler.IsInRangeOfSpawnpoint(player.World, new Vector3I(x, y, z)))
{
player.Message("You can not build a portal near a spawnpoint.");
return;
}
if (PortalHandler.GetInstance().GetPortal(player.World, new Vector3I(x, y, z)) != null)
{
player.Message("You can not build a portal inside a portal, U MAD BRO?");
return;
}
}
}
}
if (player.PortalName == null)
{
player.PortalName = Portal.GenerateName(player.World);
}
Portal portal = new Portal(player.PortalWorld, marks, player.PortalName, player.Name, player.World.Name);
PortalHandler.CreatePortal(portal, player.World);
op.AnnounceCompletion = false;
op.Context = BlockChangeContext.Portal;
op.Begin();
player.Message("Successfully created portal with name " + portal.Name + ".");
}
else
{
player.MessageInvalidWorldName(player.PortalWorld);
}
}
catch (Exception ex)
{
player.Message("Failed to create portal.");
Logger.Log(LogType.Error, "WorldCommands.PortalCreateCallback: " + ex);
}
}