title: How to to delete a world's data directory on a Bukkit server?
body: <p>In my Minecraft server plugin for Spigot/Bukkit I am trying to delete a world's data directory, but after unloading the world and its chunks, some files and directories can still not be deleted.</p>
  
  <p>Here is the significant portion of my code:</p>
  
  <pre><code>Server server = Backup.getPlugin(Backup.class).getServer();
  World world = server.getWorld("world");
  File active = world.getWorldFolder();
  
  // Unload the world.
  server.unloadWorld(world, false);
  // Unload the chunks.
  Chunk[] chunks = world.getLoadedChunks();
  for (Chunk chunk : chunks) {
      chunk.unload(false);
  }
  ServerManager.deleteDirectory(active);
  </code></pre>
  
  <p>ServerManager.deleteDirectory(File) utilizes Apache's FileUtils.deleteQuietly(File) and works for other features, but fails to delete some files in data directories of recently unloaded worlds, most likely because some files are still used by the server.</p>
  
  <p>My main question: how can I make sure the world data directory is no longer used so it can be deleted?</p>