Search in sources :

Example 1 with ClickMenuTransaction

use of org.spongepowered.common.event.tracking.context.transaction.inventory.ClickMenuTransaction in project SpongeCommon by SpongePowered.

the class TransactionSink method logClickContainer.

default EffectTransactor logClickContainer(final AbstractContainerMenu menu, final int slotNum, final int buttonNum, final ClickType clickType, final Player player) {
    @Nullable Slot slot = null;
    if (buttonNum >= 0) {
        // Try to get valid slot - might not be present e.g. for drag-events
        slot = ((InventoryAdapter) menu).inventoryAdapter$getSlot(slotNum).orElse(null);
    }
    final ClickMenuTransaction transaction = new ClickMenuTransaction(player, menu, slotNum, buttonNum, clickType, slot, ItemStackUtil.snapshotOf(player.inventory.getCarried()));
    this.logTransaction(transaction);
    return this.pushEffect(new ResultingTransactionBySideEffect(InventoryEffect.getInstance()));
}
Also used : InventoryAdapter(org.spongepowered.common.inventory.adapter.InventoryAdapter) ClickMenuTransaction(org.spongepowered.common.event.tracking.context.transaction.inventory.ClickMenuTransaction) Slot(org.spongepowered.api.item.inventory.Slot) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Aggregations

Nullable (org.checkerframework.checker.nullness.qual.Nullable)1 Slot (org.spongepowered.api.item.inventory.Slot)1 ClickMenuTransaction (org.spongepowered.common.event.tracking.context.transaction.inventory.ClickMenuTransaction)1 InventoryAdapter (org.spongepowered.common.inventory.adapter.InventoryAdapter)1