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


Java InteractItemEvent类代码示例

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


InteractItemEvent类属于org.spongepowered.api.event.item.inventory包,在下文中一共展示了InteractItemEvent类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openItemCase

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void openItemCase(InteractItemEvent.Secondary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    ItemStack item = event.getItemStack().createStack();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        Case caze = manager.getCase();
        if (!(caze instanceof ItemCase)) continue;
        ItemStack case_item = ((ItemCase) caze).getItem();
        if (!Utils.itemStacksEquals(item, case_item)) continue;
        event.setCancelled(true);
        OpenManager open_manager = manager.getOpenManager();
        if (!open_manager.canOpen(player, manager)) {
            player.sendMessage(LanguageUtils.getText("CAN_NOT_OPEN_CASE"));
            return;
        }
        Key key = manager.getKey();
        if (key.get(player) < 1) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_KEY"));
            return;
        }
        caze.add(player, -1);
        key.add(player, -1);
        manager.getOpenManager().open(player, manager);
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:29,代码来源:ItemCaseListener.java

示例2: startItemCasePreview

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void startItemCasePreview(InteractItemEvent.Primary.MainHand event) {
    Optional<Player> optional_player = event.getCause().first(Player.class);
    if (!optional_player.isPresent()) return;
    Player player = optional_player.get();
    ItemStack item = event.getItemStack().createStack();
    for (Manager manager : GWMCrates.getInstance().getCreatedManagers()) {
        String manager_id = manager.getId();
        Case caze = manager.getCase();
        if (!(caze instanceof ItemCase)) continue;
        ItemStack case_item = ((ItemCase) caze).getItem();
        if (!Utils.itemStacksEquals(item, case_item)) continue;
        event.setCancelled(true);
        if (!((ItemCase) caze).isStartPreviewOnLeftClick()) return;
        Optional<Preview> optional_preview = manager.getPreview();
        if (!optional_preview.isPresent()) {
            player.sendMessage(LanguageUtils.getText("PREVIEW_NOT_AVAILABLE",
                    new Pair<String, String>("%MANAGER%", manager.getName())));
            return;
        }
        Preview preview = optional_preview.get();
        if (!player.hasPermission("gwm_crates.preview." + manager_id)) {
            player.sendMessage(LanguageUtils.getText("HAVE_NOT_PERMISSION"));
            return;
        }
        preview.preview(player, manager);
        player.sendMessage(LanguageUtils.getText("PREVIEW_STARTED",
                new Pair<String, String>("%MANAGER%", manager.getName())));
        break;
    }
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:32,代码来源:ItemCaseListener.java

示例3: onInteractItemPrimary

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order = Order.EARLY)
public void onInteractItemPrimary(InteractItemEvent.Primary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithPrimaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by primary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:33,代码来源:VirtualChestPlugin.java

示例4: onInteractItemSecondary

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order = Order.EARLY)
public void onInteractItemSecondary(InteractItemEvent.Secondary event, @First Player player)
{
    String name = "";
    Optional<VirtualChestInventory> inventoryOptional = Optional.empty();
    for (String inventoryName : this.dispatcher.listInventories())
    {
        VirtualChestInventory inventory = this.dispatcher.getInventory(inventoryName).get();
        if (inventory.matchItemForOpeningWithSecondaryAction(event.getItemStack()))
        {
            if (player.hasPermission("virtualchest.open.self." + inventoryName))
            {
                name = inventoryName;
                inventoryOptional = Optional.of(inventory);
                event.setCancelled(true);
                break;
            }
        }
    }
    if (inventoryOptional.isPresent())
    {
        try
        {
            this.logger.debug("Player {} tries to create the GUI ({}) by secondary action", player.getName(), name);
            SpongeUnimplemented.openInventory(player, inventoryOptional.get().createInventory(player), this);
        }
        catch (InvalidDataException e)
        {
            this.logger.error("There is something wrong with the GUI configuration (" + name + ")", e);
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:33,代码来源:VirtualChestPlugin.java

示例5: onLeftClick

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onLeftClick(InteractItemEvent.Primary evt, @Root Player player) {
    PlayerLeftClicksScriptEvent event = (PlayerLeftClicksScriptEvent) clone();
    event.internal = evt;
    event.player = new PlayerTag(player);
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:10,代码来源:PlayerLeftClicksScriptEvent.java

示例6: onRightClick

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onRightClick(InteractItemEvent.Secondary evt, @Root Player player) {
    PlayerRightClicksScriptEvent event = (PlayerRightClicksScriptEvent) clone();
    event.internal = evt;
    event.player = new PlayerTag(player);
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:10,代码来源:PlayerRightClicksScriptEvent.java

示例7: onPlayerInteract

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order=Order.LAST)
public void onPlayerInteract(InteractItemEvent.Secondary event, @First Player player_sponge) {
	EPlayer player = this.plugin.getEServer().getEPlayer(player_sponge);
	
	if(player.getItemInMainHand().isPresent()){
		ItemStack item = player.getItemInMainHand().get();
		if(item.getType().equals(ItemTypes.COMPASS) && player.isCreative()){
			Optional<Vector3i> block = player.getViewBlock();
			if (block.isPresent()) {
				player.teleport(player.getWorld().getLocation(block.get().add(0, 1, 0)), true);
			}
		}
	}
}
 
开发者ID:EverCraft,项目名称:EverEssentials,代码行数:15,代码来源:EEPlayerListeners.java

示例8: onRMBClick

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
@Include({
		InteractBlockEvent.Secondary.class,
		InteractEntityEvent.Secondary.class,
		InteractItemEvent.Secondary.class
})
public void onRMBClick(InteractEvent e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.R));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:ComboListener.java

示例9: onLMBClick

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
@Include({
		InteractBlockEvent.Primary.class,
		InteractEntityEvent.Primary.class,
		InteractItemEvent.Primary.class
})
public void onLMBClick(InteractEvent e, @Root Player player) {
	IActiveCharacter character = characterService.getCharacter(player);
	e.setCancelled(characterService.processUserAction(character, UserActionType.L));
}
 
开发者ID:NeumimTo,项目名称:NT-RPG,代码行数:11,代码来源:ComboListener.java

示例10: onItemUse

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onItemUse(InteractItemEvent event) {
  if (blockedItems.contains(event.getItemStack().getType().getId())) {
    Optional<Player> optPlayer = event.getCause().first(Player.class);
    if (optPlayer.isPresent()) {
      Player player = optPlayer.get();
      player.sendMessage(Text.of(TextColors.RED, "This item has been disabled."));
    }
    event.setCancelled(true);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:ItemInteractBlockingListener.java

示例11: onUseItem

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onUseItem(InteractItemEvent.Secondary event, @Root Player player)
{
    ItemType item = event.getItemStack().getType();
    List<Region> regionsAt = manager.getRegionsAt(player.getLocation());
    Permission usePerm = pm.register(SettingsListener.class, item.getId(), "Allows interacting with a " + item.getTranslation().get() + " Item in hand", useItemPerm);
    Tristate set = checkSetting(event, player, regionsAt, () -> usePermission.get(UseType.ITEM), s -> s.use.all.item, UNDEFINED);
    if (checkSetting(event, player, regionsAt, () -> usePerm, (s) -> s.use.item.getOrDefault(item, UNDEFINED), set) == FALSE)
    {
        i18n.send(ACTION_BAR, player, CRITICAL, "You are not allowed to use this here.");
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:13,代码来源:SettingsListener.java

示例12: onCancelRepair

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onCancelRepair(InteractEvent event, @First Player player)
{
    if (event instanceof InteractBlockEvent || event instanceof InteractItemEvent)
    {
        return;
    }
    this.cancelRequest(event, player);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:ItemRepairListener.java

示例13: onInteract

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener
public void onInteract(InteractItemEvent event) {
    ModuleConfig config = Modules.BLACKLIST.get().getConfig().get();
    CommentedConfigurationNode hnode = config.get();
    ItemStackSnapshot item = event.getItemStack();
    CommentedConfigurationNode node = hnode.getNode("items", item.getType().getId());
    if (!node.isVirtual()) {
        if (node.getNode("deny-use").getBoolean()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:13,代码来源:ItemListener.java

示例14: onItemInteract

import org.spongepowered.api.event.item.inventory.InteractItemEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onItemInteract(InteractItemEvent interactItemEvent, @First Player player) {
    checkLoginStatus(interactItemEvent, player);
}
 
开发者ID:games647,项目名称:FlexibleLogin,代码行数:5,代码来源:PreventListener.java


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