Checking Who Placed a Block - Efficiently

Discussion in 'Plugin Development' started by xtremetom, Feb 27, 2014.

Thread Status:
Not open for further replies.
  1. I find myself needing to check if a block has been placed by a user or not upon block breaking.

    There are a couple of options I can use such as storing block activity in a hashmap and saving/loading data on enable/disable. Or I can use coreprotect API.

    The latter seems as though it could be heavy on mysql calls but also storing block breaking info for say 7 days in a hashmap just screams out NO!!!

    Is there an option Im missing or indeed a better way to handle this.
    I would love it if there was a NBT method for storing placement data within the block itself.
     
  2. Offline

    1Rogue

    SQL is made for data storage, you should use it if you can.
     
  3. Which method do you think would be softer on my dear old server:

    save/load hashmap data on enable/disable via SQL and reference that data as a hashmap when needed

    or

    call the SQL as needed
     
  4. Offline

    NathanWolf

    The first one. You absolutely do not want to be running a SQL query on every block place or break!
     
  5. xtremetom
    Use mongo instead of SQL, you will get much faster response times.

    [​IMG]
     
    NathanWolf likes this.
  6. Thanks and thanks, Ill look into mongo.

    Ill code this up and see what happens :)
     
  7. Offline

    NathanWolf

    Sure, but still- I wouldn't do any kind of persistent storage on those events?

    Or, maybe do, I dunno :)

    I could just be paranoid since I'm generally in the mindset of a player could modify thousands of blocks in a second, but I suppose that's not really normal. (Just don't use my plugin with your logger)

    Seriously, though- if you think your list will fit in memory, keep it in memory. Maybe do it per-chunk and watch for chunk load and unload?

    Mongo or another NoSql solution will be faster, but I think you might lose some flexibility, like being able to query on different aspects of the data, like an area or player or chunk or whatever. Unless I'm misremembering, but Mongo is basically a glorified key/value store, right? It's more efficient because it's tremendously less complicated and less flexible.
     
  8. Honestly memory wont be an issue and I plan to section the hashmap into chunks for faster data pulling after reading this, thanks :)

    But yeah I see how kids spam click so I will be uber careful the data handling.
     
    NathanWolf likes this.
  9. NathanWolf
    You can still run the same complex queries as on SQL. With mongo what you lose out on is the database relation and foreign key features.
     
    NathanWolf likes this.
Thread Status:
Not open for further replies.

Share This Page