'How to delete a world folder in Bukkit

I found many ways on the internet to delete a world folder, but nothing worked. Does anyone knows how to delete it?



Solution 1:[1]

Finally i got your problem! After the world unloads the server doesnt know it anymore.

all.teleport(Bukkit.getWorld(lobbyWorld).getSpawnLocation());

if (Bukkit.getWorld(worldName) == null) return;

File folder = Bukkit.getWorld(worldName).getWorldFolder();
Bukkit.unloadWorld(Bukkit.getWorld(worldName), false);

folder.delete();

World world = WorldCreator.name(worldName).environment(World.Environment.NORMAL).type(WorldType.NORMAL).createWorld();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Levi Heßmann