当前位置: 首页>>代码示例>>Java>>正文


Java ClickInventoryEvent.getTransactions方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.item.inventory.ClickInventoryEvent.getTransactions方法的典型用法代码示例。如果您正苦于以下问题:Java ClickInventoryEvent.getTransactions方法的具体用法?Java ClickInventoryEvent.getTransactions怎么用?Java ClickInventoryEvent.getTransactions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.item.inventory.ClickInventoryEvent的用法示例。


在下文中一共展示了ClickInventoryEvent.getTransactions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fireClickEvent

import org.spongepowered.api.event.item.inventory.ClickInventoryEvent; //导入方法依赖的package包/类
private void fireClickEvent(ClickInventoryEvent e)
{
    Optional<Player> optional = Sponge.getServer().getPlayer(playerUniqueId);
    if (!optional.isPresent())
    {
        return;
    }
    Player player = optional.get();
    CompletableFuture<Boolean> future = CompletableFuture.completedFuture(Boolean.TRUE);
    for (SlotTransaction slotTransaction : e.getTransactions())
    {
        Slot slot = slotTransaction.getSlot();
        SlotIndex pos = SpongeUnimplemented.getSlotOrdinal(slot);
        if (SpongeUnimplemented.isSlotInInventory(slot, e.getTargetInventory()) && slotToListen.matches(pos))
        {
            e.setCancelled(true);
            boolean allowAction = actionIntervalManager.allowAction(player, acceptableActionIntervalTick);
            if (allowAction && itemsInSlots.containsKey(pos))
            {
                future = future.thenApplyAsync(p -> processClickEvent(e, player, pos) && p, executorService);
            }
        }
    }
    future.thenAccept(shouldKeepInventoryOpen ->
    {
        if (!shouldKeepInventoryOpen)
        {
            SpongeUnimplemented.closeInventory(player, plugin);
        }
    });
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:32,代码来源:VirtualChestInventory.java

示例2: onInventoryClick

import org.spongepowered.api.event.item.inventory.ClickInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryClick(ClickInventoryEvent e, @Root Player player) {
    for (SlotTransaction transaction : e.getTransactions()) {
        if (ArmorType.isArmor(transaction.getFinal().getType().getId()) ||
                ArmorType.isArmor(e.getCursorTransaction().getFinal().getType().getId())) {
            sendDelayedArmorUpdate(player);
            break;
        }
    }
}
 
开发者ID:MylesIsCool,项目名称:ViaVersion,代码行数:11,代码来源:Sponge5ArmorListener.java

示例3: listen

import org.spongepowered.api.event.item.inventory.ClickInventoryEvent; //导入方法依赖的package包/类
@Listener
public void listen(ClickInventoryEvent event)
{
    List<SlotTransaction> upperTransactions = new ArrayList<>();
    int upperSize = event.getTargetInventory().iterator().next().capacity();
    for (SlotTransaction transaction : event.getTransactions())
    {
        Integer affectedSlot = transaction.getSlot().getInventoryProperty(SlotIndex.class).map(SlotIndex::getValue).orElse(-1);
        boolean upper = affectedSlot != -1 && affectedSlot < upperSize;
        if (upper)
        {
            upperTransactions.add(transaction);
        }
    }

    Inventory te = event.getTargetInventory().query(QueryOperationTypes.TYPE.of(BlockCarrier.class));
    if (!(te instanceof BlockCarrier))
    {
        te = te.first();
    }
    if (te instanceof BlockCarrier)
    {
        Action action = this.observe(event);
        action.addData(INVENTORY_CHANGES, Observe.transactions(upperTransactions));
        action.addData(Report.LOCATION, Observe.location(((BlockCarrier) te).getLocation()));
        this.report(action);
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:29,代码来源:ChangeInventoryReport.java


注:本文中的org.spongepowered.api.event.item.inventory.ClickInventoryEvent.getTransactions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。