Unload and Delete world

Discussion in 'Plugin Development' started by Muod, Apr 30, 2014.

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

    Muod

    ------------------------Unloading and Deleting a world completely during a running game----------------------

    I would like to unload and delete a world while the game is running. I want it to fully delete the world, the whole world folder. This is because the mini-game I'm making deletes and re-loads the world. Anybody know how to go about this? I have Google'd a lot about this but I just can't find the write answer I need! I need a code that can do both while the game is running. Help anybody?
     
  2. Offline

    JUSTCAMH

    Here you are. As far as I know, this method works. I haven't tested it in a while though...
    Code:java
    1. public void resetmap(World w, Player player) {
    2.  
    3. for (Player p : w.getPlayers()) {
    4. p.kickPlayer(player.getName()
    5. + " has deleted the world you are in!");
    6. }
    7.  
    8. if (Bukkit.unloadWorld(w.getName(), true)) {
    9. System.out.println("Unloaded world");
    10. } else {
    11. System.err.println("Couldn't unload world");
    12. }
    13. if (delete(new File(w.getName()))) {
    14. System.out.println("Deleted world!");
    15. } else {
    16. player.sendMessage(ChatColor.DARK_RED
    17. + "Unable to delete your world!");
    18. System.err.println("Couldn't delete world");
    19. }
    20. }

    Hope this works
     
  3. Offline

    Muod

    JUSTCAMH , Error on delete, is that even a function?
     
  4. Offline

    JUSTCAMH

    Meh as far as I know I used this on one of my plugins, I didn't even make this. It worked so that was all that mattered have you even tested this?
     
Thread Status:
Not open for further replies.

Share This Page