How do I get the used container onInventoryClickEvent?

Discussion in 'Plugin Development' started by marwzoor, Aug 14, 2012.

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

    marwzoor

    I am trying to develop a plugin which changes color of wool in a dispenser when you click on it, for example: I have a dispenser with a white wool inside, if I click the wool it turns green. Now the problem is that I only want this to happen on certain dispensers, so I need to get the location of the dispenser I am "Clicking inside". But there is no method in the InventoryClickEvent Class that gives me either block or location.

    Thanks in advance for any answers!
     
  2. the getHolder() can be an instance of the holder... it's instanceof Player if it's a workbench, enchanting table or player inventory/crafting (any maybe something else)... or it can be instance of the block its holding stuff for, like Dispenser :)

    Code:
    InventoryHolder holder = inv.getHolder();
    
    if(holder != null && holder instanceof Dispenser)
    {
        Dispenser dispenser = (Dispenser)holder;
    
        dispenser.getLocation()...
    }
     
    marwzoor likes this.
  3. Offline

    marwzoor

    Digi
    Thank you very much! :D
     
Thread Status:
Not open for further replies.

Share This Page