How to get inventory name that player is viewing?

Discussion in 'CommandHelper' started by itstake, Apr 20, 2018.

  1. itstake

    itstake New Member

    I tried get_inventory_name(puuid()) but It's not working. Any Ideas?
  2. PseudoKnight

    PseudoKnight Well-Known Member Developer

    You have to know which inventory holder they opened to use that function. There currently doesn't exist a function that returns the location or entity of the inventory holder of the inventory the player is currently viewing. However, it does seem possible with the current Bukkit API. I'll look into adding this.
  3. PseudoKnight

    PseudoKnight Well-Known Member Developer

    This is more difficult than I had hoped. heh.
  4. PseudoKnight

    PseudoKnight Well-Known Member Developer

    There's a lot of things that need to be fleshed out in the abstraction layer for this to be done correctly.
    Last edited: Apr 23, 2018
  5. PseudoKnight

    PseudoKnight Well-Known Member Developer

    So, it's done. I'm wondering if it's the correct approach, though. I'll give you an example of how it currently works.
    PHP:
    @target = get_popen_inventory(@player);
    @name = '';
    if(!is_null(@target) && @target != puuid(@player)) {
        @name = get_inventory_name(@target);
    }
    So it returns null if it's a virtual inventory and returns the player's UUID if there is no inventory open or they're viewing their own inventory. (There's no way to tell if they have their own inventory open or not)

    Does that make sense? Does the function name make sense?
  6. PseudoKnight

    PseudoKnight Well-Known Member Developer

    Maybe it should also return null if no separate inventory is open. I also want to consider what might need to be changed if we merge virtual inventories into core.
  7. PseudoKnight

    PseudoKnight Well-Known Member Developer

    I'm going deeper on this. I'm now adding virtual inventory support in core, something I've wanted to do for a while. This way I don't have to change the output of this new function later. I might also change the function name, as I'm not happy with it.