How can I detect when player receive the item?

How can I detect when player receive the item in sponge 8.0 ?

e.g.

@Listener
public void onPlayerGetItem( PlayerReceiveItemEvent e){
e.player();
e.items();
e.setCancelled(true)

}

https://jd.spongepowered.org/spongeapi/8.2.0/org/spongepowered/api/event/item/inventory/ChangeInventoryEvent.Pickup.html

1 Like

It can’t detect when player receive Item From Chest, Furance, and Container.

Ah i see what you mean. Its a bit difficult as some players wont do that in a single tick, instead they put the item in the cursor, move it and then drop it.

You could listen to

https://jd.spongepowered.org/spongeapi/8.2.0/org/spongepowered/api/event/item/inventory/ChangeInventoryEvent.html

And hope the cause system helps as well as casting of the event. Or you can listen to the event i suggested before and this

https://jd.spongepowered.org/spongeapi/8.2.0/org/spongepowered/api/event/item/inventory/container/ClickContainerEvent.Shift.Primary.html

Which will limit the events to both single tick transfers