Solved InventoryOpenEvent not firing?

Discussion in 'Plugin Development' started by DarkBladee12, May 28, 2013.

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

    DarkBladee12

    Hey guys, I recently worked on my plugin and made a new event listener with the InventoryOpenEvent in it, so every event works except the InventoryOpenEvent which is not firing... I also made a listener for this event in an other plugin to test if it will work there, but didn't work though :/ That's my code:

    Code:
    @EventHandler(priority = EventPriority.HIGH)
        public void onInventoryOpen(InventoryOpenEvent event) {
            Bukkit.broadcastMessage("open");
            Player p = (Player) event.getPlayer();
            ItemStack h = p.getItemInHand();
            if (!isGun(h)) {
                return;
            }
            if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) {
                p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
            }
            plugin.player.resetGun(p, h);
        }
    I'm using CB 1.5.2-R0.2
     
  2. Offline

    AmShaegar

    This only works if you open a chest, workbench etc.

    I couldn't find any solution for player opening their own inventory.
     
  3. Offline

    beastman3226

    Try one of the Player inventory events.
     
  4. Offline

    AmShaegar

  5. Offline

    DarkBladee12

    AmShaegar Hmm, but there must be a way how you can detect a player opening its own inventory...
     
  6. Offline

    AmShaegar

    That's all I could find:
     
  7. Offline

    DarkBladee12

    AmShaegar Ok, I think I have to do a bit a workaround or something like this, thanks though ;)
     
  8. Offline

    Jogy34

    I believe the player inventory opening is client side so I don't think you're able to retrieve when that happens
     
  9. Offline

    lycano

    According to 1.4.7-R1.0 Source InventoryOpenEvent is fired when
    • startCrafting
    • startEnchanting
    • openAnvil
    • openContainer (which is anything that counts as chest type)
    • openFurnace
    • openDispenser
    • openBrewingStand
    • openBeacon
    • openTrade (NPC interaction)
    • openCustomInventory
    • openInventory
    So it should also be triggered when a player opens his own inventory. Thats why PlayerInventoryEvent is marked as deprecated.

    Also the doc for PlayerInventoryEvent say
    Deprecated:
    Use InventoryClickEvent or InventoryOpenEvent instead, or one of the other inventory events in org.bukkit.event.inventory.
     
  10. Offline

    AmShaegar

    I agree, but if you try it, it wont fire. That's how it is.
     
  11. Offline

    lycano

  12. Offline

    evilmidget38

    DarkBladee12 The client doesn't notify the server upon the opening of its own Inventory. As such, it is impossible to detect server-side.
     
    1 person likes this.
  13. Offline

    Garris0n

    Out of curiosity, does anybody know how it requests the items to put in the inventory on open?
     
  14. Offline

    AmShaegar

    On inventory updates like InventoryClick
     
  15. Offline

    Garris0n

    Ah ok, thanks.
     
Thread Status:
Not open for further replies.

Share This Page