Can I rollback a map to it's original blocks?

Discussion in 'Spigot Plugin Development' started by ShiftingKill, Jun 7, 2019.

  1. Is it currently possible in 1.14.* to keep a log of all the original blocks in a server and over time as players create anarchy the blocks could be reset back to their original, like a decay plugin?

    I was thinking of using CoreProtect to log the blocks, but if only there was a way to keep a log of only original blocks being removed, I don't care about rolling back 10 days or 2 hours, I'd save data by only wanting to roll back to the moment the block was created by the server. I have asked their discord to no avail and so I decided to see if there is a more general way people could point me in the direction of on here.

    Basically not sure if I need to write stuff and hook CoreProtect, or if there is a way within any standalone plugin. Thank you!
  2. Are you trying to reset the world to the original state when it was generated, or after a certain point in time? Also, do you want the changes to be reverted so that the first changes are reverted first, or just so that the world reverts back randomly, or both?
  3. Honestly I'd like to just reset the world to the original state when it was generated, except for certain world guarded areas.
    It would be nice to somehow have the blocks decay after like 2 weeks to their original state, so yeah I would like it to be first changes reverted first, but if it's too much of a hassle maybe I would just do it all at once when server is inactive.
  4. Why not to just rengenrate the world with the same seed
    • Agree Agree x 1
  5. Well you could go the NMS route and generate a protochunk of vanilla untouched world and cache it locally in a variable and entirely convert it to Bukkit chunk format.Then get a chunk snapshot of current chunk and compare the converted ProtoChunk, then apply the changes you want by looking at differences in chunks and some math to determine what to change.

    In your case I would create a chunk decay event that is cancellable so you can have a way to stop it with world guard regions

    Code (Text):
    //This is how you get the code to generate the vanilla chunk that I saw in a guy's paper pr, not sure it entirely works
    //Credit: MiniDigger
    ProtoChunk protoChunk = new ProtoChunk(x, z, ChunkConverter.EMPTY);
    ((org.bukkit.craftbukkit.CraftWorld) world).getHandle().worldProvider.getChunkGenerator().createChunk(protoChunk);
  6. Maybe, GriefPrevention, it has a function called restore-to-nature (or something similar). I think that this is aimed at 'claimed' areas, but may work in other areas too.
    There is also a command to restore wilderness areas.
  7. I don't want to start over and lose the worldguard regions, there has to be a way to log blocks and then just copy it over if it's not in a protected region. Simple concept, but so many spigot forums I just found also came to no solution after huge brainstorming sessions. This is a plugin desperately needed to prevent anarchy and also maintain having very few plugins on the server. No need for anti grief if the map heals itself and worldguard is a tank so depending on that is pretty safe. GriefPrevention seems like too heavy a dependency. It looks like I'm in for a couple years of development on this one.