Removing changes to world?

Discussion in 'Plugin Development' started by ItsLeoFTW, Jan 25, 2014.

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

    ItsLeoFTW

    Hey!
    I'm currently working on a PVP minigame. The map that I am using is a map built by someone else, and I want it to reset to the original version of that world when the round of a game restarts. For example:
    [Round] Map loads
    [Player] Player gets rid of multiple blocks
    [Round] When game is over, all the broken blocks are no longer broken and the structure looks normal.
    How would I do this?
     
  2. ItsLeoFTW
    Well, if it's a separate world, after the game ends you can simply unload and then reload the world using this:

    Code:java
    1. Bukkit.unloadWorld("worldName", false);
    2. //unloads a designated world. False means that the world will not be saved


    reload the world using:

    Code:java
    1. Bukkit.getServer().createWorld(new WorldCreator("worldName"));
    2. //loads the designated world if it exists, otherwise creates a new one


    If it's an arena or something that you want to rollback, then when an in-game player breaks a block, you want to store the block type and location in a HashMap and then when the game is over, iterate through the map and replace the broken blocks

    Hope this helps :)
     
  3. Offline

    ItsLeoFTW

Thread Status:
Not open for further replies.

Share This Page