1.16.5 Help rolling back EVERY entry in CoreProtect database

Discussion in 'Spigot Plugin Development' started by ShiftingKill, Jul 4, 2020.

  1. Hello all,
    I need some ideas as to how to roll back(in code, that does it in-game) every block change from a MySQL CoreProtect database. For those who don't know, CoreProtect is a block-logging plugin that stores every* change made to a map. I want to rollback every block on the map that is older than 2 weeks, minus those blocks in a protected WorldGuard region (so don't suggest loading a pregenned backup of the map, don't suggest using a chunk regenerator either because those turn islands into ocean, I want original blocks placed back, CoreProtect is the only way(?)). I know how to do this all, so don't need any help with that, the code is all written. I need help with the computer sciencey stuff. I know I cannot store an entire dataset in memory, there are a LOT of blocks older than 2 weeks. I need to work with the database in chunks. But this seems impossible because I will need to query the entire database table in order to rule out if blocks have any newer than 2 week entries. Once I have a populated HashMap<int [], Material> of all the blocks that are older than two weeks, I will be out of memory. An idea I got so far was to just query the database for all blocks in a minecraft chunk, as hopefully ~16x16x256 blocks (worst-case) would not run me out of memory. Is this the way to go, going minecraft chunk by minecraft chunk?