Making an only-take chest!

Discussion in 'Plugin Development' started by Trollkemada, Jul 4, 2013.

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

    Trollkemada

    I'm trying to make a chest form which you can take items, but in which you cannot desposit items.

    This is what I am trying:

    http://pastebin.com/w5TejywR

    However, seems like the e.getInventory() doesn't return the inventory that the player has openned. How can I get such inventory? (Or any other idea about how to get this done?)
     
  2. Offline

    jackwilsdon

    Here's some code to get you started :)
    Code:java
    1. InventoryHolder ih = event.getInventory().getHolder();
    2. if(ih instanceof Block) {
    3. Block b = (Block) ih;
    4. if (b.getType().equals(Material.CHEST)) {
    5. // Chest!
    6. }
    7. }
    This checks whether the inventory is owned by a block, and if it is, if the block is a chest :)
     
  3. Offline

    LucasEmanuel

    jackwilsdon
    You could just check if it's an instance of a chest directly ;)
     
  4. Offline

    jackwilsdon

Thread Status:
Not open for further replies.

Share This Page