Using player.openInventory it now requires the inventory and a Cause.
I’ve I’m opening another player’s inventory on a command, what do I put as the Cause veriable?
You’d… put the relevant cause?
Cause.of(NamedCause.source(commandSource), NamedCause.of("Plugin", pluginContainer))
Are you able to explain that?
Coming from Bukkit, and causes are still brand new to me.
In Bukkit, things like what caused something to happen are entirely implementation-handled and hardcoded. Sponge has a heavy theme of abstraction, and this extends to things like this.
A Cause is literally what caused something to happen. You choose what’s relevant. Listeners to this event will then be able to see what caused the event to happen.
For example, if I was to use the cause I defined above, then someone else might have a listener like so:
@Listener
public void openInv(InteractInventoryEvent.Open e, @Root CommandSource src) {
Causes are heavily tracked. If you push a button, which fires off a redstone contraption, that shoots an arrow, that kills a player who was carrying an item, you’d show up in the DropItemEvent.Destruct.
I love your example
That pie_flavor for you