Chest Database

Discussion in 'Archived: Plugin Requests' started by Forecaster, Aug 25, 2012.

  1. Offline

    Forecaster

    Introduction:
    Hello. I'm running a small dedicated bukkit server that is nothing special. But alongside this I have something we call The Dungeon.

    The Dungeon is a separate server consisting of a massive complex of rooms and corridors. About once a week a bunch of players venture in as one of 8 character classes and try to survive through the traps, mobs and puzzles and grab as much loot as they can.

    Running and building the dungeon is mostly great fun, but we've encountered one annoying problem. The chests. At it's full size (we've just torn it down to revise it) the dungeon contained well over 200 single chests, and we found that it's really difficult and time consuming to check on them all to make sure they have something in them, or to even find them all in the massive labyrinth that is the Dungeon.

    The Dungeon Entrance:
    [​IMG]

    The Plugin:
    What we would like to make this easier is a plugin that would periodically scan the world for chests and add them to a MySQL database, along with their contents, or lack thereof.

    This would allow me to write a webpage that would let us view the chests contents and their location.

    If possible I would also like the plugin to be able to update the chests contents based on the database. That would enable us to look over the chests and make sure they're nice and full from the comfort of the website.

    The Database:
    The database can be fairly simple. It only needs one table with four fields as far as the plugin is concerned.

    x, y, z, & contents

    The first three are obviously the coordinates of the chest. Contents would be an array of item id's representing the items the chest contains.
    Formatted something like this: 1x35:4;64x4; could be 1 yellow wool block and a stack of cobblestone.
    ; would be a separator so I can easily explode the string on the webpage.

    I would greatly appreciate if someone could make this plugin, or if one already exist point me to it. Although I did look and couldn't find one.
    The closest I got was Chest-Control but it does not use MySQL. (It's also not released yet.)
     
  2. Offline

    np98765

    Well, you could use ChestRestock to be able to restock the chests? It's not exactly what you're asking for, but it would be much easier for you. ^_^
     
  3. Offline

    Forecaster

    We could, but for one thing it would add an extra process when placing new chests. And it would also make it much more difficult to change the contents in the chests. Because we like to move things around to avoid having players learn where the best loot is.
     
  4. Offline

    QuantumDev

    This sounds like a very interesting plugin to make, when do you need it by?

    I'm currently making it, so I'll post a link once done :)

    Just about done, this one was actually moderately difficult.

    I tried checking every chunk (on load) for chests, but it would only find natural ones, so I ended up checking when you open a chest, and when you close it (so you'll have to go put stuff in the chests before the plugin will recognize them). Here's a pic of 5 chests in PhpMyAdmin:

    [​IMG]

    Now I have to add updating the chests contents via changing the contents column in the database (I think that's how you wanted it?).

    Be back soon.

    Forecaster

    Here you go, PLEASE note that this is a beta version (not heavily tested), so be weary until you've had a chance to use it for a while. I'd backup your map first (just in case, all chest inventories could be deleted by who knows what). The possibility of anything remotely close to that is near zero, but just be careful.

    Use

    /chests reload

    to reload all chests from the database.

    Download, unzip in your plugins folder, and change the config.yml:

    https://dl.dropbox.com/s/i4suizlc8yxsxxi/RemoteChest.zip?dl=1

    And here's the source if you're interested (it's a little messy :p, and has NO documentation):

    https://github.com/QuantumPlugins/RemoteChests

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  5. Offline

    Forecaster

    Excellent work so far! The plugin appears to work fine at the moment.

    I noticed that just opening and closing a chest will add it to the database, whether it's empty or not.

    Is it possible to have it add a chest to the database when one is placed? It's possible to forget to open a chest while you're building, and it would mean having to locate the missing chest, or having a player find an empty chest during a run.

    I also noticed that when there's a double chest it will list the contents in both chest parts in the database.

    I might be able to have the web interface detect adjacent chests and disregard one of them, so this may not be an issue.
     
  6. Offline

    QuantumDev

    Alright, now when you place a chest, it will be added to the database.

    Personally, I think it'd be better if you handled the double chest issue on your side, I think it would degrade performance (or not even notice it) if I checked all the chests.

    Same download link above
     
  7. Offline

    Forecaster

    I have started working on the web interface and it's done to the extent that it lets you view the contents of the registered chests.

    I have yet to add elements that allow editing the contents.
    Nor have I started working on the double chest problem yet. But I will do that tomorrow most likely.

    One minor enhancement I'd like is if the plugin notes empty slots in a chest as air (0).

    This would let me make the interface display the actual position of the items in the chest, instead of collapsing them.

    Could you do this?

    Did you change the config?

    I got a whole bunch of errors when trying the new version and they looked like they had something to do with the mysql connection.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2016
  8. Offline

    Forecaster

  9. Offline

    QuantumDev

    Sorry, I've been busy and will be busy today. I'll add the features and check out that error then.
     
  10. Offline

    Forecaster

    Just want you to know I really appreciate this, and there is no imminent deadline.

    When 1.3 was released we tore down most of the dungeon and are now rebuilding it to get something fresh. It will probably be about a month or so before we've built and connected enough rooms for it to be usable.

    And even in it's current state the plugin will be an invaluable tool to find empty chests. Although that error is keeping it from working properly at the moment.
     
  11. Offline

    QuantumDev

    Forecaster

    Haha, leaving the items in order (with air) would have been easier to do than what I did :)

    Reverted that, so now it should show air in the slots, and everything should be in proper order.

    The MySQL error was caused by MySQL, apparently they close all statements after 8 hours, so trying to use it after it's closed, throws errors :) That also should be fixed now.

    I tested the order addition (not heavily), but not the MySQL issue (although it should be fixed).

    https://dl.dropbox.com/s/i4suizlc8yxsxxi/RemoteChest.zip?dl=1

    Let me know if it works :)
     
  12. Offline

    Forecaster

    Seems to be working perfectly. The MySQL issue we'll see when it's been running for a longer period, but it seems to be working as well.

    I'm currently fixing up a few issues with the interface. Namely that the stack count in the chest list is wrong for some reason. I'm also working on having it tell the difference between single and double chests.

    I have implemented the air functionality.
     
  13. Offline

    QuantumDev

    Good to hear :)
     
  14. Offline

    Forecaster

    Got this error when trying to interract with a chest after the server had been running for several days.

    http://pastebin.com/ekhh60as

    Seems the issue is still present. Or I forgot uploading the new file...
     
  15. Offline

    QuantumDev

    Alright, fixed that one, same download link as before.
     
  16. Offline

    Forecaster

    Okay... whoof, lots of stuff figured out...

    1.
    The /chests reload command works great. The problem is that if you take items out of a chest it will update the database accordingly. Meaning that you'll never be able to use it for anything since the actual chest and the image on the website will always be identical. I tested the function by emptying the chest with world edit, thus preventing the database from updating.

    I would suggest adding a permission node that would be used to check the player opening the chest. If the player does not have the node then the database will not be updated with the changes to the chest. That way after a run we can just do /chests reload to restore all the chests.

    2.
    I've managed to teach the interface to tell the difference between single and double chests using the number of available slots. This system works, but there are a few drawbacks. One is that it assumes that the chests are in order.
    This is because when it hits a double chests (when going through the list by ID) it automatically skips the next double chest it finds. Though this seems to work so far.

    3.
    The data values for potions appears to be wrong in the database. This causes potions to not be displayed on the website.
     
  17. Offline

    Forecaster

    That MySQL connection problem is still present it seems. And the problem with potions is still present as well.

    Also the permission thing would be nice.

    Versions would be nice too so I can keep track of them...
     

Share This Page