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


Java InteractInventoryEvent.Open方法代码示例

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


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

示例1: onInventoryOpen

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryOpen(InteractInventoryEvent.Open event, @First Player player)
{
    if (!(event.getTargetInventory() instanceof CarriedInventory)
     || !((CarriedInventory) event.getTargetInventory()).getCarrier().isPresent())
    {
        return;
    }
    Object carrier = ((CarriedInventory) event.getTargetInventory()).getCarrier().get();
    Location<World> loc = null;
    if (carrier instanceof BlockCarrier)
    {
        loc = ((BlockCarrier) carrier).getLocation();
    }
    else if (carrier instanceof Entity)
    {
        loc = ((Entity) carrier).getLocation();
    }
    Lock lock = this.manager.getLockOfInventory(((CarriedInventory) event.getTargetInventory()));
    if (lock == null) return;
    lock.handleInventoryOpen(event, event.getTargetInventory(), loc, player);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:23,代码来源:LockerListener.java

示例2: fireOpenEvent

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
private void fireOpenEvent(InteractInventoryEvent.Open e)
{
    Optional<Player> optional = Sponge.getServer().getPlayer(playerUniqueId);
    if (optional.isPresent())
    {
        Player player = optional.get();
        Container targetContainer = e.getTargetInventory();
        Inventory targetInventory = targetContainer.first();
        plugin.getVirtualChestActions().submitCommands(player, parsedOpenAction, ImmutableList.of());
        if (updateIntervalTick > 0)
        {
            Task.Builder builder = Sponge.getScheduler().createTaskBuilder().execute(task ->
            {
                if (player.getOpenInventory().filter(targetContainer::equals).isPresent())
                {
                    refreshMappingFrom(targetInventory, updateInventory(player, targetInventory));
                }
                else
                {
                    task.cancel();
                }
            });
            builder.delayTicks(updateIntervalTick).intervalTicks(updateIntervalTick).submit(plugin);
        }
        logger.debug("Player {} opens the chest GUI", player.getName());
        plugin.getScriptManager().onOpeningInventory(player);
        refreshMappingFrom(targetInventory, updateInventory(player, targetInventory));
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:30,代码来源:VirtualChestInventory.java

示例3: onInventoryOpened

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
		public void onInventoryOpened(InteractInventoryEvent.Open event) {
			Optional<Player> cause = event.getCause().first(Player.class);
			if (cause.isPresent()) {
	//			openShops.remove(cause.get().getUniqueId());
//				VillagerShops.l("%s opened and inventory %s", cause.get().getName(), event.getTargetInventory().getName());
			} else {
//				VillagerShops.w("Can't get player opening inventory");
			}
		}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:11,代码来源:EventListeners.java

示例4: onPlayerInteractInventoryOpen

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractInventoryOpen(InteractInventoryEvent.Open event, @First Player player) {
    if (!GPFlags.INTERACT_INVENTORY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
        return;
    }

    GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.startTimingIfSync();
    final Cause cause = event.getCause();
    final EventContext context = cause.getContext();
    final BlockSnapshot blockSnapshot = context.get(EventContextKeys.BLOCK_HIT).orElse(BlockSnapshot.NONE);
    if (blockSnapshot == BlockSnapshot.NONE) {
        GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
        return;
    }

    final Location<World> location = blockSnapshot.getLocation().get();
    final GPClaim claim = this.dataStore.getClaimAt(location);
    final GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
    if (playerData.lastInteractItemBlockResult == Tristate.TRUE) {
        GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
        return;
    }

    final Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INVENTORY_OPEN, player, blockSnapshot, player, TrustType.CONTAINER, true);
    if (result == Tristate.FALSE) {
        Text message = GriefPreventionPlugin.instance.messageData.permissionInventoryOpen
                .apply(ImmutableMap.of(
                "owner", claim.getOwnerName(),
                "block", blockSnapshot.getState().getType().getId())).build();
        GriefPreventionPlugin.sendClaimDenyMessage(claim, player, message);
        ((EntityPlayerMP) player).closeScreen();
        event.setCancelled(true);
    }

    GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:37,代码来源:PlayerEventHandler.java

示例5: onChestOpen

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onChestOpen(InteractInventoryEvent.Open event, @Root Player player) {
  Optional<GoldRushInstance> optInst = manager.getApplicableZone(player);
  if (!optInst.isPresent()) {
    return;
  }

  GoldRushInstance inst = optInst.get();

  Inventory inventory = event.getTargetInventory();
  if (!inst.isLocked() && inventory instanceof ContainerChest) {
    IInventory chestInv = ((ContainerChest) inventory).getLowerChestInventory();
    if (chestInv instanceof ILockableContainer) {
      LockCode newLockCode = new LockCode(UUID.randomUUID().toString());
      tileEntityClaimMap.put(newLockCode.getLock(), player);
      ((ILockableContainer) chestInv).setLockCode(newLockCode);

      BigDecimal risk = Optional.ofNullable(
          inst.cofferRisk.get(player.getUniqueId())
      ).orElse(BigDecimal.ZERO);

      Collection<org.spongepowered.api.item.inventory.ItemStack> queue = CofferValueMap.inst().satisfy(risk.toBigInteger());
      Iterator<org.spongepowered.api.item.inventory.ItemStack> it = queue.iterator();
      for (int i = 0; i < chestInv.getSizeInventory(); ++i) {
        if (it.hasNext()) {
          chestInv.setInventorySlotContents(i, tf(it.next()));
          continue;
        }
        chestInv.setInventorySlotContents(i, ItemStack.EMPTY);
      }
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:34,代码来源:GoldRushListener.java

示例6: onOpenInventory

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

示例7: observe

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Override
public Action observe(InteractInventoryEvent.Open event)
{
    Action action = newReport();
    action.addData(CAUSE, Observe.causes(event.getCause()));
    // TODO get TargetInventory
    return action;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:9,代码来源:InventoryOpenReport.java

示例8: onOpenInventory

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onOpenInventory(InteractInventoryEvent.Open evt){
	scheduleInventoryUpdate(evt.getTargetInventory(), true);
}
 
开发者ID:TBlueF,项目名称:RottenFood,代码行数:5,代码来源:RottenFood.java

示例9: onOpenInventory

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

示例10: onInteractInventory

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

示例11: onInventoryOpen

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.EARLY)
public void onInventoryOpen(InteractInventoryEvent.Open e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.E));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:6,代码来源:ComboListener.java

示例12: listen

import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void listen(InteractInventoryEvent.Open event, @First Player player)
{
    report(observe(event));
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:6,代码来源:InventoryOpenReport.java


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