fCraft.WorldManager.FindWorldOrPrintMatches C# (CSharp) Method

FindWorldOrPrintMatches() private method

private FindWorldOrPrintMatches ( [ player, [ worldName ) : World
player [
worldName [
return World
        public static World FindWorldOrPrintMatches( [NotNull] Player player, [NotNull] string worldName )
        {
            if ( player == null )
                throw new ArgumentNullException( "player" );
            if ( worldName == null )
                throw new ArgumentNullException( "worldName" );
            if ( worldName == "-" ) {
                if ( player.LastUsedWorldName != null ) {
                    worldName = player.LastUsedWorldName;
                } else {
                    player.Message( "Cannot repeat world name: you haven't used any names yet." );
                    return null;
                }
            }
            player.LastUsedWorldName = worldName;

            World[] matches = FindWorlds( player, worldName );

            if ( matches.Length == 0 ) {
                player.MessageNoWorld( worldName );
                return null;
            }

            if ( matches.Length > 1 ) {
                player.MessageManyMatches( "world", matches );
                return null;
            }
            return matches[0];
        }

Usage Example

Example #1
0
        public static void Stop(Player player, bool Won)
        {
            if (Failed != null && Mines != null)
            {
                Failed.Clear();

                foreach (Vector3I m in Mines.Values)
                {
                    Vector3I removed;
                    Mines.TryRemove(m.ToString(), out removed);
                }
            }
            World world = WorldManager.FindWorldOrPrintMatches(player, "Minefield");

            WorldManager.RemoveWorld(world);
            WorldManager.SaveWorldList();
            Server.RequestGC();
            instance = null;
            if (Won)
            {
                Server.Players.Message("{0}&S Won the game of MineField!", player.ClassyName);
            }
            else
            {
                Server.Players.Message("{0}&S aborted the game of MineField", player.ClassyName);
            }
        }
All Usage Examples Of fCraft.WorldManager::FindWorldOrPrintMatches