Chest doesn't always close

Discussion in 'Plugin Development' started by theone_123, Jul 30, 2014.

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

    theone_123

    Hi!
    I'm having a problem on closing chests in my plugin. If the player enters a command the inventory of a specific chest is opened with openInventory(). This works perfectly. There is also a method that prevents the player from taking items from the chest. This happens within an InventoryClickEvent. This is also working flawlessly.

    But when the player closes this inventory with ESC or E the chest sometimes stays open. This happens only sometimes. Do you have any idea how to proberly close it? I also tried to send a packet with playnote to the chest that should close it. But this didn't work either.

    This opens the Inventory:
    Code:java
    1. Block block = mailBoxLoc.getBlock();
    2. if (block.getType() == Material.CHEST) {
    3. BlockState bs = block.getState();
    4. if (bs instanceof DoubleChest) {
    5. player.openInventory(((DoubleChest) bs)
    6. .getInventory());
    7. return true;
    8. } else {
    9. player.openInventory(((Chest) bs)
    10. .getInventory());
    11. return true;
    12. }
     
  2. Offline

    Totom3

    That's weird... Did you try with an InventoryCloseEvent handler in which you test if the inventory is a mail box and then do something like this :
    Code:java
    1. event.getView().close();
     
  3. Offline

    fireblast709

    theone_123 sounds like a visual bug (assuming the inventory gets closed like usual)
     
Thread Status:
Not open for further replies.

Share This Page