Inventory Owner

Discussion in 'Plugin Development' started by Deleted user, Jan 6, 2014.

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

    Deleted user

    How do you get the owner of an inventory?
     
  2. Offline

    Xephiro

    JHG0
    I don't now if it's posible but try with the next code

    Code:java
    1. public Player getInventoryOwner(Inventory inventory)
    2. {
    3. for(HumanEntity h: inventory.getViewers())
    4. {
    5. if (h instanceof Player)
    6. {
    7. Player p = (Player)h;
    8. if (p.getInventory().equals(inventory))
    9. {
    10. return p;
    11. }
    12. }
    13. }
    14. return null;
    15. }


    I make this, but i don't make any test to the code xD

    Good Luck
     
  3. Offline

    leimekiller

    Code:java
    1.  
    2. Inventory inv = Bukkit.createInventory(null, 1);
    3. inv.getHolder();
     
  4. Offline

    Deleted user

  5. Offline

    leimekiller

    JHG0 "Gets the block or entity belonging to the open inventory "
     
  6. Offline

    Paxination

    Code:
     if(inv.getHolder() instance of Player) {
    BLAH BLAH BLAH!
    }
     
Thread Status:
Not open for further replies.

Share This Page