What does getOpenInventory() return

I’m currently working on my plugin, and I had a quick question that I can’t test right now: what does Player#getOpenInventory() do? Does it return the whole inventory, or just the sub-inventory. Basically, if I call clear() on it, will it remove the player’s items, or just the items of the sub-inventory being viewed?

It returns the viewed Container. So usually this is the viewed inventory + main player inventory + hotbar.

Well… that is kind of annoying. How do I get the viewed inventory out of that?

Iterate through the sub-inventories. The first one is usually the viewed inventory.
or just container.first()