Best way to restart a server without saving?

Discussion in 'Spigot Plugin Development' started by iHolden, Jul 5, 2015.

  1. Hello,

    I'm trying to make this as descriptive as possible, but anyways, what I need is code, or a way to auto restart a server without saving, why? Well, I'm in the process of creating a mini-game, and I need a way to restart it without saving, because the map & game auto-reboots after.

    Currently this is the code I am using.
    Code (Text):

                        if (Settings.restart()){
    Any help is appreciated. Thank you!
  2. Disable auto save increments and then run this code before shutting down the server. Doesnt even need to shutdown server for this rollback, either).

    Code (Text):

        //Unloading maps, to rollback maps. Will delete all player builds until last server save
        public static void unloadMap(String mapname){
            if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
                plugin.getLogger().info("Successfully unloaded " + mapname);
                plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
        public static void loadMap(String mapname){
            Bukkit.getServer().createWorld(new WorldCreator(mapname));

        //Maprollback method, because were too lazy to type 2 lines
        public static void rollback(String mapname){
    Source: Google search, first result:
  3. @BillyGalbreath , thank you! I've had experience with you on these forums before & you're quite helpful. I was looking at your shutdown notice plugin before I made this thread as well. :D
    • Friendly Friendly x 1
  4. is impossible
    • Funny Funny x 1
  5. You're welcome! ^_^

    Also, if the methods above dont work, you could try physically deleting the world directory after unloading it and then copying a save back into place. If its not too large of a world, this will work fine. If its large, it might delay your shutdown process quite a bit.
  6. It's a small world, literally. :rolleyes:

    Nothing's impossible.
  7. if shutdown then not on this server.
  8. What? I can't understand you..
  9. Unfortunately you can't uload the main world
  10. You should be able to if you have another world loaded, iirc. As long as at least one world stays loaded at all times things should be fine. (I could be wrong, i never tried this).
  11. Yeah, if you have another world loaded should be fine :D
  12. Note that chunks are saved when they are unloaded regardless of the auto-save option. The auto-save option keeps saving LOADED chunks at an interval. Say you have a survival world where your spawn is always loaded, then you might want to enable auto-save so that the spawn should be loaded, the other chunks in the world should be unloaded from time to time, meaning they will get saved every now and then.

    The way I do it for all my mini-game plugins is that I have a source-world. Copy the source folder on startup. Load the world from the copy. Then use the loaded copy. Then delete the world when the game is over.

    PS: I usually move the delete part to the start of the process (before coping) in case the server stopped/crashed for some reason and there are left over files.