Deleting a world?

Discussion in 'Plugin Development' started by Ty Cleere, Oct 5, 2013.

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

    Ty Cleere

    I am wanting to delete a world without shutting off the server. Anyone know how? Thanks!
     
  2. Offline

    MrSparkzz

    Ty Cleere
    You cannot do it without shutting down the server. I'm not sure about multiple worlds though...

    You could try this:
    • kicking all players
    • unloading the world
    • deleting the world folder
     
    Goblom likes this.
  3. Offline

    RainoBoy97

  4. Offline

    stonar96

    It is possible to delete a world, when you teleport all players out of the world, and kick all death players in the world and then wait some ticks with a scheduler and then use this:
    Code:java
    1. getServer().unloadWorld(wName, true);

    After doing this, it should be possible to delete the world.

    Edit: I use it in my plugin without any errors.

    Edit: But I donĀ“t think that this works for the mainworld.
     
  5. Offline

    Ty Cleere

    MrSparkzz I was thinking that but how would i get the world folder and delete that?
     
  6. Offline

    MrSparkzz

    Ty Cleere
    This might be it
    Code:java
    1.  
    2. if (args.length == 1) {
    3. World playerworld = Bukkit.getWorld(player.getName() + "-world");
    4. File playerworldfolder = new File(player.getName() + "-world");
    5. Bukkit.getServer().unloadWorld((playerworld), isInitialized()); //unload world
    6. //delete world folder and all contents under the directory and delete the "playerworldfolder" OR "playerworld"
    7. if (!(playerworldfolder==null)){ // if the world folder is still there (meaning it didn't delete) then send a message saying "failed"
    8. sender.sendMessage("failed");
    9. }
    10. }
    11.  
     
  7. Offline

    Ty Cleere

  8. Offline

    Skyost

    Ty Cleere You can enable your plugins before the worlds was loaded and delete it with a code ;)
     
Thread Status:
Not open for further replies.

Share This Page