Offer Inventory?

Hello everyone, does anyone know if it’s possible to offer or query an inventory to a player? I’ve tried:
player.getInventory().query(pInv); but it’s that simple.

Both your question and your code are very unclear.

I think he wants to transfer the contents from one inventory over to another

1 Like

Query to a Player makes no sense. What would querying an inventory for another do?

Offering another inventory could make sense ( inventory#offer(anotherInventory) ) but its currently not possible like this.
Make an Issue for it on SpongeAPI; we might add it.

For now you can iterate through the slots and offer the items if present.

// smth. like this
for (Inventory slot : pInv.slots()) {
   if (slot.peek().isPresent()) {
       player.getInventory().offer(slot.peek().get());
   }
}
1 Like

@DosMike Was right. I wanted to be able to transfer an existing Inventory instance to a player, thus replacing the player’s current inventory with the instance.