World rollback

Discussion in 'Plugin Development' started by xXMaTTHDXx, Sep 22, 2014.

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

    xXMaTTHDXx

    Hey, I am making a minigame currently and it involves destroying alot of stuff lol. I have my rollback methods:

    Code:java
    1. public static void unloadMap(String mapname){
    2. if(Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)){
    3. plugin.getLogger().info("Successfully unloaded " + mapname);
    4. }else{
    5. plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
    6. }
    7. }
    8. //Loading maps (MUST BE CALLED AFTER UNLOAD MAPS TO FINISH THE ROLLBACK PROCESS)
    9. public static void loadMap(String mapname){
    10. Bukkit.getServer().createWorld(new WorldCreator(mapname));
    11. }
    12.  
    13. //Maprollback method, because were too lazy to type 2 lines
    14. public static void rollback(String mapname){
    15. unloadMap(mapname);
    16. loadMap(mapname);
    17. }


    When I call it, then world doesnt get rolled back, there are no players in that world!
     
  2. Offline

    Jimfutsu

    xXMaTTHDXx
    To my belief, simply unloading the world doesn't roll back the world. What I would do is I would create a cuboid for the section you want rollbacked, then log each block in there. After when you want to rollback, you can just repleace all the blocks with the ones you want.
     
  3. Offline

    CoolGuy2001

    Yeah, or use the WorldEdit API to store the region, then recover it when you need rollback!
     
Thread Status:
Not open for further replies.

Share This Page