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


Java InventoryClickEvent.getCurrentItem方法代码示例

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


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

示例1: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    ItemStack button = event.getCurrentItem();
    if (button == null || button.getType() == Material.AIR) {
        return;
    }
    Inventory inventory = event.getInventory();
    PageGUI gui = PageGUI.getByInventory(inventory);
    if (gui == null) {
        return;
    }

    event.setCancelled(true);
    PageGUI.playSound(event);
    int index = gui.getPages().indexOf(inventory);
    HumanEntity player = event.getWhoClicked();
    if (button.equals(NEXT_PAGE)) {
        gui.open(player, index + 1);
    } else if (button.equals(PREVIOUS_PAGE)) {
        gui.open(player, index - 1);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:23,代码来源:PageGUICache.java

示例2: onInventoryClick1

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                    player.closeInventory();
                    player.teleport(targetPlayer);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
 
开发者ID:SlamTheHam,项目名称:UltraCore,代码行数:23,代码来源:Events.java

示例3: onInventoryClick2

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
 
开发者ID:SlamTheHam,项目名称:UltraCore,代码行数:23,代码来源:Events.java

示例4: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
void onInventoryClick(InventoryClickEvent event) {
	if (event.getInventory().getTitle().contains("Emoji List")) {
		event.setCancelled(true);
		if (event.getCurrentItem() != null && event.getCurrentItem().getType() == Material.DIAMOND && event.getCurrentItem().hasItemMeta()
				&& event.getCurrentItem().getItemMeta().hasDisplayName()) { // Make sure the item clicked is a page change item
			try {
				int currentPage = Integer.parseInt(event.getInventory().getTitle().split(" ")[3]) - 1; // Get the page number from the title
				
				if (event.getCurrentItem().getItemMeta().getDisplayName().contains("<-")) { // Back button
					event.getWhoClicked().openInventory(plugin.emojiChatGui.getInventory(currentPage - 1));
				} else { // Next button
					event.getWhoClicked().openInventory(plugin.emojiChatGui.getInventory(currentPage + 1));
				}
			} catch (Exception e) { // Something happened, not sure what, so just reset their page to 0
				event.getWhoClicked().openInventory(plugin.emojiChatGui.getInventory(0));
			}
		}
	}
}
 
开发者ID:RadBuilder,项目名称:EmojiChat,代码行数:21,代码来源:EmojiChatListener.java

示例5: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = false)
public void onInventoryClick(InventoryClickEvent e) {
	ItemStack item = e.getCurrentItem();
	if (item != null) {
    	    if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getKitMenuItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getKitMenuItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
        	} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getExitGameItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getExitGameItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
     	} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getSpectateItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getSpectateItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
     	} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getJoinItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getJoinItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
		} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getOptionsItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getOptionsItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
		} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getLobbyMenuItem().getData().getItemType()) &&  item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getLobbyMenuItem().getEnchantments().keySet()))) {
			e.setCancelled(true);
		}
	}

}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:21,代码来源:PlayerListener.java

示例6: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	Player p = (Player) event.getWhoClicked();
	Inventory inv = event.getInventory();
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("Voting Panel")) {
		event.setCancelled(true);
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		ItemStack i = event.getCurrentItem();
		Map m = Map.getByTitle(Chat.stripColor(i.getItemMeta().getDisplayName()));
		if (m != null) {
			m.addVote(p);
			p.closeInventory();
			event.setCancelled(true);
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:18,代码来源:VotePanelEvents.java

示例7: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent e){
    Player p = (Player) e.getWhoClicked();
    WCUser user = new WCUser(p.getUniqueId());
    Inventory inv = e.getClickedInventory();
    ItemStack i = e.getCurrentItem();

    switch (ChatColor.stripColor(inv.getName())){
        case "Servidores":
            switch (e.getSlot()){
                case 21:
                    user.sendToServer("survival");
                    break;

                default:
                    break;
            }
            break;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:21,代码来源:InventoryEvent.java

示例8: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent evt){
    if(evt.getCurrentItem() == null || evt.getCurrentItem().getType() == Material.AIR){
        return;
    }
    if(evt.getClickedInventory().getTitle() == null || !evt.getClickedInventory().getTitle().equals(name)){
        return;
    }

    evt.setCancelled(true);
    for(KitType type : KitType.values()){
        if(type.getDisplayNameWithColor().equals(evt.getCurrentItem().getItemMeta().getDisplayName())){
            if(!KitCallBack.isCallingBack(evt.getWhoClicked().getName()))
                lobby_Statistics.getInstance().getApi().getData(evt.getWhoClicked().getName(), DataType.walls, new KitCallBack(evt.getWhoClicked().getName(), type));
            break;

        }
    }
    evt.getWhoClicked().closeInventory();
}
 
开发者ID:JHXSMatthew,项目名称:CSGO_lobby,代码行数:21,代码来源:KitController.java

示例9: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (INCOME_MANAGEMENT.equals(button)) {
        faction.getTradeMenu().open(player);
    } else if (TRADE_OFFER.equals(button)) {
        plugin.getCommandCache().tradeOffer.onExecute(new String[]{"tradeOffer", faction.getName()}, player);
    } else if (STORAGE.equals(button)) {
        plugin.getCommandCache().storage.onExecute(new String[]{"storage", faction.getName()}, player);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:19,代码来源:EconomyMenu.java

示例10: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack clicked = event.getCurrentItem();
    Inventory inventory = event.getInventory();

    if (inventory.getName().equals("Faction Management")) {

        if (clicked.getType() == Material.SKULL_ITEM) {
            if (event.getClick() == ClickType.LEFT) {
                Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.MIDDLE){
                Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.RIGHT) {
                Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:25,代码来源:FactionManagerArgument.java

示例11: click

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public void click(InventoryClickEvent event) {
	event.setCancelled(true);
	ItemStack stahck = event.getCurrentItem();
	for(InvGuiItem item : items) {
		if(item != null && item.getStack().equals(stahck)) {
			item.click(event.getClick());
			return;
		}
	}
}
 
开发者ID:cjburkey01,项目名称:BurkeyShop,代码行数:11,代码来源:GuiShop.java

示例12: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent e) {
    Inventory inventory = e.getClickedInventory();
    Player p = (Player) e.getWhoClicked();

    if (e.getClickedInventory() == null) return;
    if (e.getCurrentItem() == null) return;
    if (!this.menuHashMap.containsKey(p.getName())) return;
    if (inventory.getTitle().equals("") || inventory.getTitle().isEmpty()) return;

    Menu menu = getMenu(p);
    if (menu == null) return;
    if (menu.getElement(e.getRawSlot()) == null) return;
    menu.getElement(e.getRawSlot()).click(e);
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:16,代码来源:MenuManager.java

示例13: onInventoryClickEvent

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent event) {
	ItemStack itemStack = event.getCurrentItem();
	if (itemStack != null && itemStack.getType() == Material.ENDER_PEARL) {
		ItemMeta itemMeta = event.getCurrentItem().getItemMeta();
		itemMeta.setDisplayName(null);
		event.getCurrentItem().setItemMeta(itemMeta);
	}
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:10,代码来源:EnderpearlListener.java

示例14: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onClick(InventoryClickEvent e) {
	if (!cm.isAntiNegativeItemDupe) {
		return;
	}
	ItemStack item = null;
	if (e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR) {
		item = e.getCurrentItem();
	} else if (e.getCursor() != null && e.getCursor().getType() != Material.AIR) {
		item = e.getCursor();
	}
	if (item != null && item.getAmount() <= 0) {
		item.setType(Material.AIR);
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:16,代码来源:AntiNegativeItemDupe.java

示例15: onGroupsClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private void onGroupsClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    ItemStack button = event.getCurrentItem();
    event.setCancelled(true);
    PageGUI.playSound(event);
    IdeaGroup group = IdeaGroup.getByIcon(button);
    if (event.getClick() == ClickType.SHIFT_LEFT) {
        boolean selected = group.select(faction);
        MessageUtil.sendMessage(player, (selected ? FMessage.IDEA_MENU_GROUPS_SELECTED : FMessage.IDEA_MENU_GROUPS_DESELECTED).getMessage(group.getName()));
        openGroups(player);
    } else {
        openIdeas(player, group);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:15,代码来源:IdeaMenu.java


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