Solved InventoryCloseEvent Help please verry fast

Discussion in 'Plugin Development' started by MrEpic, Apr 4, 2014.

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

    MrEpic

    This code dosen't work!

    Code:java
    1. @EventHandler
    2. public void onInventoryCloseEvent(InventoryCloseEvent e){
    3. Inventory inv = e.getInventory();
    4. InventoryHolder holder = inv.getHolder();
    5.  
    6. if(holder != null && holder instanceof Chest){
    7. Chest chest = (Chest) holder;
    8. Block block = chest.getBlock();
    9.  
    10. if (block.getType() == Material.TRAPPED_CHEST);
    11.  
    12. if (block.isEmpty()){
    13. block.setType(Material.AIR);
    14. }
    15. }
    16. }
     
  2. Offline

    Zethariel

    Any errors? Did you try and debug it with messages?

    Also, not sure that InventoryHolder will return instanceof Chest. Think it can return a doublechest or something else too.
     
  3. Offline

    MrEpic

    I got nothing no error its didint work but residual in the Plugin works :/
     
  4. Offline

    Zethariel

    Did you set the class this method is in as listener?
     
  5. Offline

    PePsiGam3r

    if (block.isEmpty()) ??
    Idk but did you meant here, if the inventory had no items in it? or what.
     
  6. Offline

    MrEpic

    Yes this is the eventclass of a big plugin whif other events in this class

    But whif out this it's isnt work too

    Please the event of my server is in 3 days

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  7. Offline

    AoH_Ruthless

    MrEpic
    Please learn java... you have an if-statement followed by a semi-colon.

    Also, in your instance check, the holder can't be null.
    The block also can't be empty, if you've defined it to be a chest..
     
  8. Offline

    MrEpic

    Sorry Im learn java but is verry difficut :(
     
Thread Status:
Not open for further replies.

Share This Page