'Rollback' worlds for PVP arena

Discussion in 'Plugin Development' started by scarabcoder, Dec 9, 2013.

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

    scarabcoder

    I'm working on a plugin/server with PVP kits, and some of them are destructive. I want to know how to make it so when the game ends, it restores the world to it's un-destroyed state. Is there any code for this?
     
  2. Offline

    The_Doctor_123

    You could copy all the block data into multi-dimensional arrays. Or get Chunk Snapshots.
     
  3. Offline

    scarabcoder

  4. Offline

    Twisted_Panda

    Then just don't even try, if you didn't understand. But it's my opinion.
     
  5. Offline

    XvBaseballkidvX

    scarabcoder You could just add block regeneration methods. So people can still break blocks/blow stuff up, but the blocks will regenerate automatically at a later time.
     
  6. Offline

    NathanWolf

    You should always try!

    But the short answer is no, there is no easy way to do this, you've got to brute-force it. What we are suggesting is you loop through all of the blocks you want to save, and store their state somehow. A list of objects with x,y,z coordinates and material/data might be a simple approach.

    When you want to restore, loop through your array and re-set all the stored blocks.

    You can search around for some example code that might help get you started, but this is relatively simple stuff and generally people don't like to spoonfeed code :)
     
  7. Offline

    scarabcoder

  8. Offline

    XvBaseballkidvX

    scarabcoder For the block breaking (If you want that). You would need listen to a block break event, get the location, and type of that block, then use a runnable to replace that block "x" amount of ticks later.

    For Explosion regeneration, listen to an EntityExplodeEvent get the list of all the blocks effected by the explosion:
    Code:java
    1. for(Block block : event.blockList(){
    2. }


    Get the blocks location, and material. Use a runnable to replace those blocks "x" amount of ticks later.
    I will give you some code in a little bit.
     
  9. Offline

    scarabcoder

    How do I do pauses though? I made a pause, but it lagged up the server :(
     
  10. Offline

    Compressions

    scarabcoder Schedule a task. Please do not put the main thread to sleep.
     
Thread Status:
Not open for further replies.

Share This Page