Detecting chest inventory updating?

Discussion in 'Plugin Development' started by Acrobot, Mar 27, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Acrobot

    Is there any way to check if chest's inventory has changed?
    In JavaDocs there is INVENTORY_CHANGE event, but it hasn't got any description and when checking craftbukkit's source code, I couldn't find anything that could handle the event.
    So, how can I accomplish it?

    Thanks in advance :)
     
  2. Offline

    Gandalf

    I have the same question as well, I need events for when someone opens, and closes a chest.

    So I can see what is added to the players inventory.

    Also is there any way to detect what is removed?
     
  3. Offline

    Edward Hand

    Those events aren't implemented yet (no idea why).

    We'll just have to patient.
     
  4. Offline

    Gandalf

    Alrighty, thank you, I appreciate the response.

    Is there any way to make a patchwork implementation of this to work?
     
  5. Offline

    narrowtux

    No, you have to hack the minecraft server code for this.

    An other way could be to look if the player moves or quits or chats after he opened a chest. That would mean that he already closed the chest and you can do your thing after this happens.
     
  6. Offline

    Edward Hand

    Although you have to be careful. Detecting moving would certainly be a good way, but you don't want security to be breached when a user gets nudged by a sheep...

    Checking the following to see whether the player's inventory window is still open:
    Code:
    CraftPlayer cPlayer = (CraftPlayer)thePlayer;
    if(cPlayer.getHandle().activeContainer == cPlayer.getHandle().defaultContainer)
    {
       //inventory is closed
    }
    (used in conjunction with narrowtux's suggestion you get both security and efficiency)
     
Thread Status:
Not open for further replies.

Share This Page