How can I check which inventory the player has opened?

Discussion in 'Plugin Development' started by MrKoLoTeR, May 20, 2021.

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

    MrKoLoTeR

    How can I check which inventory the player has opened? For example Donkey, Llama, etc.
    Tried using the code below nothing happens.. Hope someone can help..

    @EventHandler
    public void Horse(InventoryOpenEvent e) {
    if(e.getInventory() instanceof HorseInventory){
    e.setCancelled(true);
     
  2. Offline

    davidclue

    @MrKoLoTeR I believe you have to use AbstractHorseInventory instead.
     
  3. Offline

    KarimAKL

    @MrKoLoTeR Check if the inventory is an instance of AbstractHorseInventory, then get the InventoryHolder and check if it is an instance of one of the following:
    Horse
    Donkey
    Mule
    Llama
    SkeletonHorse
    ZombieHorse
     
  4. Offline

    MrKoLoTeR

    Thank you all for your help! Works!
     
Thread Status:
Not open for further replies.

Share This Page