本文整理汇总了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);
}
});
}
示例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;
}
}
}
示例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);
}
}