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


Java InteractInventoryEvent.Close方法代码示例

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


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

示例1: onInteractInventoryEventClose

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInteractInventoryEventClose(InteractInventoryEvent.Close event) throws IOException, SQLException {
    final Container container = (Container) event.getTargetInventory();

    if (container instanceof ContainerChest) {
        final ContainerChest containerChest = (ContainerChest) container;

        if (containerChest.getLowerChestInventory() instanceof BackpackInventory) {
            final BackpackInventory inventory = (BackpackInventory) containerChest.getLowerChestInventory();
            final Backpacks record = inventory.getRecord();

            final Session session = DatabaseManager.getSessionFactory().openSession();
            session.beginTransaction();
            for (int i = 0; i < record.getSize(); i++) {
                final ItemStack stack = (ItemStack) (Object) inventory.getStackInSlot(i);
                DatabaseManager.saveSlot(session, record, i, stack == null ? null : stack.toContainer());
            }
            session.getTransaction().commit();
            session.close();
        }
    }
}
 
开发者ID:AlmuraDev,项目名称:Backpack,代码行数:23,代码来源:Backpack.java

示例2: manageClose

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void manageClose(InteractInventoryEvent.Close event) {
    Container container = event.getTargetInventory();
    if (FirstGuiPreview.FIRST_GUI_CONTAINERS.containsKey(container)) {
        FirstGuiPreview.FIRST_GUI_CONTAINERS.remove(container);
    } else if (SecondGuiPreview.SECOND_GUI_CONTAINERS.containsKey(container)) {
        SecondGuiPreview.SECOND_GUI_CONTAINERS.remove(container);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:10,代码来源:PreviewListener.java

示例3: cancelClose

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void cancelClose(InteractInventoryEvent.Close event) {
    Container container = event.getTargetInventory();
    if (!FirstOpenManager.SHOWN_GUI.contains(container) &&
            FirstOpenManager.FIRST_GUI_CONTAINERS.containsKey(container) &&
            FirstOpenManager.FIRST_GUI_CONTAINERS.get(container).getKey().isForbidClose()) {
        event.setCancelled(true);
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:10,代码来源:FirstGuiOpenManagerListener.java

示例4: fireCloseEvent

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
private void fireCloseEvent(InteractInventoryEvent.Close e)
{
    Optional<Player> optional = Sponge.getServer().getPlayer(playerUniqueId);
    if (optional.isPresent())
    {
        Player player = optional.get();
        plugin.getVirtualChestActions().submitCommands(player, parsedCloseAction, ImmutableList.of());
        logger.debug("Player {} closes the chest GUI", player.getName());
        actionIntervalManager.onClosingInventory(player);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:12,代码来源:VirtualChestInventory.java

示例5: onInventoryClosed

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
	public void onInventoryClosed(InteractInventoryEvent.Close event) {
		Optional<Player> cause = event.getCause().first(Player.class);
		if (cause.isPresent()) {
			UUID target = cause.get().getUniqueId();
			VillagerShops.openShops.remove(target);
			VillagerShops.actionUnstack.remove(target);
//			l("%s closed an inventory", cause.get().getName());
		} else {
//			l("An inventory was closed");
		}
	}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:13,代码来源:EventListeners.java

示例6: onCloseInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player player, @Getter("getTargetInventory") Container inventory)
{
    // When closing update filters and prompt activation
    if (inventory instanceof CarriedInventory && inventory.size() > 0)
    {
        ((CarriedInventory<?>) inventory).getCarrier().ifPresent(carrier -> this.promptActivation(carrier, true, player));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:ItemDuctTransferListener.java

示例7: onCloseInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player player, @Getter("getTargetInventory") Container inventory)
{
    // When closing update filters
    if (inventory instanceof CarriedInventory<?>) {
        ((CarriedInventory<?>) inventory).getCarrier().ifPresent(carrier -> {
            if (carrier instanceof DuctFilterCarrier)
            {
                ((DuctFilterCarrier) carrier).update(event.getTargetInventory().iterator().next());
            }
        });
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:14,代码来源:ItemDuctFilterListener.java

示例8: onInventoryClose

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryClose(InteractInventoryEvent.Close event, @First Player player)
{
    Container inventory = event.getTargetInventory();
    if (inventory instanceof CarriedInventory)
    {
        if (((CarriedInventory)inventory).getCarrier().orElse(null) instanceof BackpackHolder)
        {
            BackpackHolder holder = (BackpackHolder)((CarriedInventory)inventory).getCarrier().get();
            holder.getBackpack().closeInventory(inventory, player);
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:14,代码来源:BackpackManager.java

示例9: onCloseInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close e, @First Player p) {
	manager.removePlayer(p.getUniqueId());
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:5,代码来源:ContainerAccessListener.java

示例10: onInteractInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent.Close event) {
    webHookService.notifyHooks(WebHookService.WebHookType.INVENTORY_CLOSE, event);
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:5,代码来源:WebAPI.java

示例11: onCloseInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(final InteractInventoryEvent.Close event, @Root Player player) {
    this.stopThem.remove(player.getUniqueId());
}
 
开发者ID:ichorpowered,项目名称:latch,代码行数:5,代码来源:InteractBlockListener.java

示例12: PlayerMoveInv

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void PlayerMoveInv(InteractInventoryEvent.Close e, @Root Player p){
	RPUtil.removeGuiItem(p);
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:5,代码来源:RPPlayerListener.java

示例13: onDeath

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onDeath(InteractInventoryEvent.Close event){
	if (event.getTargetInventory().getName().get().equals(this.inv.getName().get())){
		close();
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:7,代码来源:RPGui.java

示例14: onCloseInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player p) {
    //Player closed invsee
    UltimateUser up = UltimateCore.get().getUserService().getUser(p);
    up.offer(InventoryKeys.INVSEE_TARGET, null);
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:7,代码来源:InventoryListener.java

示例15: close

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void close(InteractInventoryEvent.Close event, @First Player player) {
    Container inv = event.getTargetInventory();
    if (!(inv.getViewers().contains(viewer))) {
        return;
    }

    if (!player.getUniqueId().equals(viewer.getUniqueId()) && player.hasPermission(Permissions.ADMIN)) {
        return;
    }

    if (!inv.getName().equals(inventory.getName())) {
        return;
    }

    SpongeItemBank.instance().map(SpongeItemBank.class::cast).ifPresent(plugin -> {
        SpongeConfig config = plugin.getConfig();
        IntStream.range(0, inv.capacity()).forEach(x -> getItem(inv, x).filter(is -> is.getType() != ItemTypes.AIR).ifPresent(itemStack -> {
            itemAmount = 0;
            StreamSupport.stream(inv.spliterator(), false).map(Inventory::peek).filter(Optional::isPresent).map(Optional::get).filter(is -> is.getType() != ItemTypes.AIR && itemStack.getType() == is.getType() && IBUtils.isSameVariant(itemStack, is)).forEach(is -> itemAmount += itemStack.getQuantity());
            ItemStack configItem = config.getItem(itemStack);
            if (configItem != null && config.isWhitelist()) {
                handleMaxAmount(inv, x, configItem, itemStack, player);
            }
            else if (configItem == null && config.isWhitelist()) {
                spawnItem(itemStack, player.getLocation());
                setItem(inv, x, ItemStack.empty());
                hasIllegalItems = true;
            }
        }));

        if (hasIllegalItems) {
            player.sendMessage(Text.builder(Messages.ACCOUNT_ILLEGAL_ITEM).color(TextColors.RED).build());
        }

        if (hasIllegalAmount) {
            player.sendMessage(Text.builder(Messages.ACCOUNT_ILLEGAL_AMOUNT).color(TextColors.RED).build());
        }

        IntStream.range(0, inv.size()).forEach(slot -> getItem(inv, slot).ifPresent(itemStack -> {
            if (itemStack.getType() == ItemTypes.AIR) {
                page.clearSlot(slot);
            }
            else {
                page.setSlot(new AccountSlot<>(slot, itemStack));
            }
        }));
    });

    Sponge.getEventManager().unregisterListeners(this);
}
 
开发者ID:Musician101,项目名称:ItemBank,代码行数:52,代码来源:SpongeInventoryHandler.java


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