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.
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.
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
I've never worked with WorldGuard either untill recently, so i just asked in the PluginDevelopment section
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.
PHP: BlockState state = block.getState();// ... do what you need to do with the blockstate...state.update();
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?
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