Restore an area

Discussion in 'Plugin Development' started by pixlepix, Jun 24, 2012.

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

    pixlepix

    So, im stumped. I want a plugin to take an area, and when a certain event happens, to restore all changes made to the arena, like in the war plugin(Note that the area is based off chunks). I have been reading the javadocs for days and I cant figure out a solution. Any help would be great.

    Anyone have any idea? Could really use some advice.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  2. you can hook into worledit, and call functions from it
     
  3. Offline

    pixlepix

    Is there a tutorial on that? The javadoc isnt very informative
     
  4. Offline

    Log-out

    First you must save BlockState from every block of the region you want to restore into HashMap.
    Then if you want to restore the region, you just load the BlockState and update it.
     
  5. Offline

    hammale

    u could just regenerate the chunk...
     
  6. Offline

    desht

    Nothing like that simple, sorry. You need to consider persistence, containers, the order in which you restore blocks...
    If the terrain that needs restoring has been previously changed by players, those changes would be lost too. However, if there's a guarantee that this is happening on wild terrain, that's a viable option.

    ferrybig is right - the best way to do this is to hook WorldEdit. There is no tutorial for this that I know of; when I added terrain backup/restoration to ChessCraft, I did it the hard way - I went and looked at the WorldEdit source and worked out what the relevant commands did - //cut //paste //save //load, then I hooked the WorldEdit API. However, you're welcome to look at my ChessCraft code: https://github.com/desht/ChessCraft...me/desht/chesscraft/blocks/TerrainBackup.java
     
  7. Offline

    Lolmewn Retired Staff

    Someone should write a tutorial on how to hook into WorldEdit. Sounds like a job for me! :D
     
    ferrybig and ZeusAllMighty11 like this.
  8. Offline

    Drew1080

    If you are going to write one for WorldEdit you should write on for WorldGuard.
     
  9. Offline

    Lolmewn Retired Staff

    Yeah, I might. Never worked with WorldGuard though :)
     
  10. Offline

    Drew1080

    I've never worked with WorldGuard either untill recently, so i just asked in the PluginDevelopment section
     
  11. Offline

    gregroberti

    How do you load the BlockState? It doesn't look like they provide a .setState(BlockState) function for Block..

    EDIT: I got it to work by setting my Block's Type to my saved BlockState's Type and my Block's Data to my saved BlockState's RawData.. a bit unintuitive.
     
  12. Offline

    desht

    PHP:
    BlockState state block.getState();
    // ... do what you need to do with the blockstate...
    state.update();
     
  13. run an chest, place an chest whit contents, destroy it, restore and see what you forgot
     
  14. Offline

    gregroberti

    I'm running into that problem.. I can save and restore an entire area, however, not everything is back to how it was. Certain things *pop* out of place like doors, beds and crops.. while other items like signs just reset. Chests spill their contents out all over the floor. Any suggestions?
     
  15. place first solid block, then the non-solids to fix signs
    save the contents of an chest, and clear them, restore then when you restore
     
Thread Status:
Not open for further replies.

Share This Page