Listen on a Chest

Discussion in 'Plugin Development' started by xasz, Jan 29, 2012.

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

    xasz

    Hello people,

    i am searching for a nice way to listen on a chestchange. I need the amount of items of the chest, after the player closed the chest.
    I searched for an event like
    Code:
    public onChestChange(onChestChangeEvent event){
    //count items
    }
    or much more better would be
    Code:
    public onChestClose(onChestCloseEvent event){
    //count items
    }
    But, unhappily there is no such event. What would be the best solution to listen for this, without wasting cpu time.

    thanx for your help
     
  2. Offline

    TopGear93

  3. Offline

    nisovin

  4. Offline

    Technius

  5. For exapmle use the "InventoryListener();" - still old event system, the event is:

    Code:JAVA
    1.  
    2. Event.Type.INVENTORY_CHANGE;
    3.  
     
  6. Offline

    xasz

    Thanx for your replys.
    I saw the InventoryListener too, but i only saw this methods:
    Code:
    Public Member Functions
        InventoryListener ()
    void    onFurnaceBurn (FurnaceBurnEvent event)
        Called when an ItemStack is successfully burned as fuel in a furnace.
    void    onFurnaceSmelt (FurnaceSmeltEvent event)
        Called when an ItemStack is successfully smelted in a furnace. 
    How can i use the Inventory_Change event ?
     
  7. Offline

    RROD

    TopGear93 You sure it isn't this?

    Code:Java
    1. @EventHandler
    2. public void onPlayerInventory(PlayerInventoryEvent event){
    3. Inventory inv = event.getInventory();
    4. if(inv instanceof Chest){
    5. //do intemstack code in here.
    6. }
     
  8. Offline

    MuisYa

    RROD Whaaaat, is that possible? Didn't know that. Thanks!
     
    RROD likes this.
  9. Offline

    TopGear93

    Woops, your right about that. i must of been thinking about spout's event :p
     
    MuisYa and RROD like this.
  10. Offline

    xasz

    I tried now some differnt ways, but i haven't got a working code.

    Wether the old plugin system nor the old plugin system is helping me.

    Someone got an Idea, how to check this without using spout code.
     
Thread Status:
Not open for further replies.

Share This Page