Iterate through SQLite CoreProtect database?

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

  1. Broad question but does anyone have any ideas on how to "iterate" through the CoreProtect SQLite database using spigot? I basically want it to run through each block from the top of the db down, checking if the time in the database is 2 weeks older than the current time (I'll figure that part out) and spitting out a value or "block location" for each entry. By spitting out I mean I want to "execute something" on each, I don't need to save it anywhere, just want the current block location to go get checked, then the next one gets checked, and so on.
    • I saw the CoreProtect db lists changes to blocks top to bottom, increasing downward with time.
    • How can someone, in bukkit/spigot, make a method for this, something relative to that of a for loop?
    • For each entry in the db, spit out the block location (x,y,z). I need this to later check if that block is in a WorldGuard region, effectively automatically determining what to rollback or not after x amount of time.
     
  2. To query the database you can use the JDBC with the SQLite driver. Instead of getting all of the rows in a table to check the time just make SQL query that filters for blocks that are 2 weeks old. I can help you more if you tell me the column names and what data is stored in them.
     
  3. Hello tchristofferson,
    First of all, I'd like to thank you for your help so far. I'd say I'm a novice at spigot/craftbukkit plugin development and inexperienced with the database side of things. I might need a tutorial on the SQLite driver and JDBC stuff as I have not heard of either besides my brief reading in this link Processing SQL Statements with JDBC on the Oracle docs site. Is this the appropriate documentation to get started? Attached is a screenshot of the database using DB Browser. Here is the imgur of a screenshot of both the general structure of the database as well as an example of the block shtuffs. Thank you! Also, anyone out there even a brief introduction to how databases are intertwined with spigot/Java plugins would be helpful because it seems like a foreign thing that Java just naturally has a way to open a database and search it.