fCraft.WorldManager.FindWorlds C# (CSharp) Method

FindWorlds() public static method

Finds all worlds that match the given name. Autocompletes. Raises SearchingForWorld event. Target worlds are not guaranteed to have a loaded map.
public static FindWorlds ( [ player, [ name ) : fCraft.World[]
player [ Player who is calling the query. May be null.
name [ Full or partial world name.
return fCraft.World[]
        public static World[] FindWorlds( [CanBeNull] Player player, [NotNull] string name )
        {
            if ( name == null )
                throw new ArgumentNullException( "name" );
            World[] matches = FindWorldsNoEvent( name );
            var h = SearchingForWorld;
            if ( h != null ) {
                SearchingForWorldEventArgs e = new SearchingForWorldEventArgs( player, name, matches.ToList() );
                h( null, e );
                matches = e.Matches.ToArray();
            }
            return matches;
        }

Usage Example

Example #1
0
        internal static World FindWorldMatches(Player player, string name)
        {
            if (name == "-")
            {
                if (player.LastUsedWorldName != null)
                {
                    name = player.LastUsedWorldName;
                }
                else
                {
                    player.Message("Cannot repeat world name: you haven't used any names yet.");
                    return(null);
                }
            }
            player.LastUsedWorldName = name;
            World[] matches = WorldManager.FindWorlds(player, name);

            if (matches.Length == 0)
            {
                player.MessageNoWorld(name);
                return(null);
            }
            else if (matches.Length > 1)
            {
                player.MessageManyMatches("world", matches);
                return(null);
            }
            return(matches[0]);
        }
All Usage Examples Of fCraft.WorldManager::FindWorlds