fCraft.WorldCommands.WorldUnload C# (CSharp) Method

WorldUnload() static private method

static private WorldUnload ( Player player, Command cmd ) : void
player Player
cmd Command
return void
        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();
        }