Do I need the Inventory API?

I want to create a little plugin to store content of my enderchests in a mysql database.
What I need:

  • An event that fires, when a player opens an enderchest. (check - just use the InteractBlockEvent in combination with .Primary / .Secondary and add a if to check if the target block is an enderchest)

  • When this event gets fired, I have to pull all items from database, delete all items in the enderchest and insert all items from database, because I want to be able to change them on my website (check?)

  • When a user takes/places an item from/in the enderchest, I need an event which supports to get information about the new item (size of the stack, id, variant) and slot-id to save this change in my database (check?)

If there are requested features, that are not supported right now, can you say me, when they will be implemented? (Is the implementation of the inventory api included in beta? / Is there a list of all features included in beta?)

My database would look like this (tables)
*count(stack size)

Helpful answers would be great,
Thanks :smile:

No, you do not need the inventory api, inventory EVENTS are currently implemented. Assuming you know how to work with SQL (I don’t, so I can’t help with that) all you need is the right events and to work with the frighteningly-complex-but-actually-quite-simple Data API (to get the information you want).

Note: for CLEARING the chest, you may need the inventory API, however there is either some sort of ContainerData you could reset, or you could just ‘cheat’ and place a new ender chest where the old one was.

Edit: Place an enderchest? What idiot said that… Oh wait…
As @gabizou said, that won’t work…

Do you remember the enderchest mechanics? The inventory is a virtual inventory based on the player’s ender chest inventory.

Yep, thats the problem. I really have to clear the enderchest and put the items stored in my database in my enderchest again.

So I can place / add new Items to an enderchest without using the Inventory API?
I have no problem when I have to use the Inventory API, but it isn’t out now :slightly_smiling:

As of beta, the core of the inventory API is now merged (queries, accessing playing inventory), over the next few weeks the functionality will be fleshed out to cover Containers and other Carriers so you should be able to do what you want soon™


Thank you :slightly_smiling:
Can you say me how I can use import org.spongepowered.api.text.sink.MessageSink and MessageSinkEvent in Beta? I just can’t find it…

It was renamed to MessageChannel and MessageChannelEvent in

1 Like