How can I delete a world? (This is not supposed to be a prank)

Discussion in 'Plugin Development' started by Kierrow, Jan 19, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Kierrow

    Hey, I'm currently developing a plugin which would allow you to draw your world
    (click here if you want to know some more).
    However, to generate biomes (not the world itself), I have set up a world generator which
    generates an empty world. This way, there won't be any time wasted on that.
    So I want to get the biomes of the world, this is why it creates a temporary one, which
    is the only way I've found to generate biomes based on a seed unfortunately.
    However, after I'm done working with the world, I'd like to delete it, as it's a temp world...
    But that is not possible.
    The only way I've tried is
    Code:
    [World].getWorldFolder().delete();
    but that doesn't seem to work...

    So how can I do it?
    Of course, if you know a way to generate biomes without a temp world, but based on a seed,
    that would be cool too =P

    Thanks in advance,
    Kierrow

    EDIT:
    I did unload the world before trying to delete it.
     
  2. Offline

    Fishrock123

    I do believe your trying to delete files that are being used by a program, and windows (and other OSes) don't like that.

    Your best bet is to modify the vanilla world generator to only generate biome data.
     
  3. Offline

    DrAgonmoray

    It's probably what Fishrock said. You'll want to unload the world, then remove it.
    getServer().unloadWorld([world]);
     
  4. Offline

    Kierrow

    Yeah I tried that. There has to be another way...
     
  5. Offline

    nisovin

    You have to delete it recursively. Something like this:

    Code:
        private void deleteFolder(File file) {
            if (file.isDirectory()) {
                File[] files = file.listFiles();
                for (File f : files) {
                    deleteFolder(f);
                }
            }
            file.delete();
        }
    
     
    Chiller, Kierrow and DrAgonmoray like this.
  6. Offline

    DrAgonmoray

    I wouldn't worry about it. If a user wants to delete a world, they should do that, not the plugin. Thats likely why there is no "delete world" method implemented.
     
Thread Status:
Not open for further replies.

Share This Page