Deleting a world and replacing it with a backup?

Discussion in 'Plugin Development' started by willeb96, Dec 9, 2012.

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

    willeb96

    Hi!

    How would I go about deleting a world and then copying the files from /worldname_backup?

    Thanks for any advice :)
     
  2. Offline

    tommycake50

    the moving files part should be simpleish java.
    first you need to unload the world or its gonna throw an error.
    Bukkit.unloadWorld(name, false);
    then delete the world file.
    then create a new file with the desired name.
    and move over all the files from worldname_backup.
    then simply reload the server.
     
  3. Offline

    willeb96

    tommycake50 Can I unload the main world on the server if I kick all players before I do so?
     
  4. Offline

    bergerkiller

    willeb96
    No. You can not, ever, unload the main worlds. It's simply how CraftBukkit works.

    (Well technically you can, but I don't think you are into complicated reflection and class replacement routines)
     
  5. Offline

    willeb96

    Could I have 1 flat world which is the main one, but keep all players in a separate one and sort of treat this separate one as if it was the main one then?
     
  6. Offline

    tommycake50

    you will be able to get away with not unloading the world if the server is hosted on linux.
    not sure about windows windows can be a bit of a bitch.
     
    Ahmet094 likes this.
  7. Offline

    bergerkiller

  8. Offline

    RainoBoy97

    My thoughts, for a HungerGames plugin (example) is:

    Main world.
    HungerGames world.
    Everyone is in the Main world.
    Before game start teleport all players to HungerGames world.
    At end teleport all players to Main world.
    Delete HungerGames world.
    Rename/Make HungerGames world.
    Teleport all players to HungerGames world.
     
    fireblast709 likes this.
  9. Offline

    Barinade

    You could use an external program/batch file to do it and write a plugin that launches the program then shuts the server down, and when the program is finished it boots the server back up.
     
  10. Offline

    tommycake50

    thats kinda a long way to remake a world but i guess its fine.
    you just have to do what i said in my first post then it really shouldnt be too hard.
    if it fails then your gonna have to do some debugging :/

    the problem with batch is that most servers are hosted on linux he should make a check if the server is linux or windows or mac.
    if linux or mac run an sh file.
    if windows run a batch file.
    and dont shut down the server just unload the world.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  11. Offline

    fireblast709

    That is basically the way to do it
    You would basically have to close the reader/writer objects to the world, to clear the file lock. Otherwise you cannot delete the file (you will probably get an error concerning the file lock). Though, as bergerkiller wrote, you probably do not want to do this :3
     
Thread Status:
Not open for further replies.

Share This Page