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


Java InventoryClickEvent.getInventory方法代码示例

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


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

示例1: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked(); // The player that
    // clicked the item
    //UUID playerUUID = player.getUniqueId();
    Inventory inventory = event.getInventory(); // The inventory that was

    if (openPanels.containsKey(player.getUniqueId())) {
        if (inventory.getName().equals(openPanels.get(player.getUniqueId()).getInventory().getName())) {
            Panel panel = openPanels.get(player.getUniqueId());

            for (int slot : panel.getItems().keySet()) {
                if (slot == event.getRawSlot()) {
                    if(!panel.getItems().get(slot).getClickHandler().onClick(player, ClickType.LEFT)) {
                        event.setCancelled(true);
                    }
                }
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:22,代码来源:PanelListener.java

示例2: 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

示例3: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onClick(InventoryClickEvent event) {
    if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) {
        return;
    }
    Inventory inventory = event.getInventory();
    if (inventory.getTitle().equals(groups.getTitle())) {
        onGroupsClick(event);
    }
    for (Entry<IdeaGroup, Inventory> gui : ideas.entrySet()) {
        if (gui.getValue().getTitle().equals(inventory.getTitle())) {
            onIdeasClick(event);
            break;
        }
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:17,代码来源:IdeaMenu.java

示例4: onClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
/**
 * Handle the GUI stuff.
 */
@EventHandler
public void onClick(InventoryClickEvent event) {

    Inventory inventory = event.getInventory();
    if (inventory.getTitle().contains("Summary for ")) {
        event.setCancelled(true);

        ItemStack item = event.getCurrentItem();
        Player viewer = (Player) event.getWhoClicked();
        if (item.getType() == Material.IRON_SWORD) {
            Player player = Bukkit.getPlayer(inventory.getTitle().split(" ")[2]);
            if (player == null) {
                viewer.sendMessage(ChatColor.RED + "This player has logged out.");
                viewer.closeInventory();
                return;
            }

            Arc.getArcPlayerManager().scheduleBan(player);
        }

    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:27,代码来源:InventoryListener.java

示例5: onInventoryClick

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

	if (p.getGameMode() != GameMode.CREATIVE)
		event.setCancelled(true);
	
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("MC Zone Games")) {
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		GameIcon game = GameIcon.get(event.getCurrentItem());
		if (game != null) {
			p.teleport(game.getTo());
			p.closeInventory();
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:19,代码来源:CompassEvents.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 // Prevents players from selling custom items and crafting with them.
public void onClick(InventoryClickEvent evt) {
    if (!(evt.getInventory() instanceof MerchantInventory) || evt.getRawSlot() != 2)
        return;

    MerchantInventory mi = (MerchantInventory) evt.getInventory();
    List<ItemStack> ig = new ArrayList<>();
    try {
        ig = mi.getSelectedRecipe().getIngredients();
    } catch (Exception e) {
        for (int i = 0; i < 3; i++) // Interal CraftBukkit throws an error, this avoids it.
            ig.add(new ItemStack(Material.DIRT));
    }

    for (int i = 0; i < evt.getInventory().getSize() - 1; i++)
        if (ItemWrapper.isCustom(evt.getInventory().getItem(i)) && !ItemWrapper.isCustom(ig.get(i)))
            evt.setCancelled(true); // Don't allow the trade to go through if it's using a custom item where none is needed.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:19,代码来源:Items.java

示例8: onClickGUI

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onClickGUI(InventoryClickEvent e) {
	Inventory inv = e.getInventory();
	if (inv == null) {
		return;
	}
	if (i18n.tr("title").equals(inv.getTitle())) {
		e.setCancelled(true);
	}
	if (e.getWhoClicked() instanceof Player) {
		Player p = (Player) e.getWhoClicked();
		int slot = e.getRawSlot();
		if (slot < 0 || slot > inv.getSize()) {
			return;
		}
		GUISortPing guiSortPing = GUISortPingHolder.get(p);
		if (guiSortPing != null) {
			if (slot == 44) {
				p.openInventory(guiSortPing.getPreviousPage());
			} else if (slot == 53) {
				p.openInventory(guiSortPing.getNextPage());
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:26,代码来源:GUISortPingListener.java

示例9: 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

示例10: onRepair

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onRepair(InventoryClickEvent event) {
	if(event.isCancelled() || !(event.getWhoClicked() instanceof Player) || !(event.getInventory() instanceof AnvilInventory))
		return;
	
	InventoryView view = event.getView();
	int rawSlot = event.getRawSlot();
	
	if(rawSlot != view.convertSlot(rawSlot) || rawSlot != 2)
		return;
	
	ItemStack item = event.getInventory().getItem(0);
	if(!plugin.getAbilityManager().hasAbility(item) || !plugin.getAbilityManager().isTemporaryItem(item))
		return;
	
	Ability ability = plugin.getAbilityManager().getAbility(item);
	event.getInventory().setItem(0, plugin.getAbilityManager().removeItemLore(item, ability));
	event.setCancelled(true);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:20,代码来源:AbilityListener.java

示例11: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
    if (e.getClickedInventory() == e.getInventory())
        onClick(e);
    if (e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
        if (getHistory((Player) e.getWhoClicked()) != null)
            e.setCancelled(true);
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:10,代码来源:GuiManager.java

示例12: onPlayerClickTrinket

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerClickTrinket(InventoryClickEvent event) {
    if (event.getInventory() instanceof CraftInventoryCrafting && event.getRawSlot() == 45) { //offhand slot
        event.setCancelled(true);
        if (event.getWhoClicked().getGameMode() != GameMode.ADVENTURE && event.getWhoClicked().getGameMode() != GameMode.SURVIVAL) {
            event.getWhoClicked().getInventory().setItemInOffHand(null);
        }
        if (event.getWhoClicked() instanceof Player)
            ((Player) event.getWhoClicked()).updateInventory();
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:12,代码来源:TrinketManager.java

示例13: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
	if(!(e.getWhoClicked() instanceof Player))
		return;
	
	Inventory inv = e.getInventory();
	InventoryHolder holder = inv.getHolder();
	if(holder != null && holder instanceof Menu)
	{
		Menu menu = (Menu) holder;
		menu.onClick(e);
	}
}
 
开发者ID:timtomtim7,项目名称:SparseBukkitAPI,代码行数:15,代码来源:MenuManager.java

示例14: onBackpackClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBackpackClick(final InventoryClickEvent event) {
    final Inventory inventory = event.getInventory();
    final Player player = (Player) event.getWhoClicked();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (inventory.getHolder() instanceof BackpackHolder) {
        // Click inside backpack
        if (BackpackManager.isBackpack(event.getCurrentItem())
                || BackpackManager.isBackpack(event.getCursor())
                || InventoryManager.isFilledSlot(event.getCurrentItem())
                || InventoryManager.isFilledSlot(event.getCursor())) {
            event.setCancelled(true);
            return;
        }

        // Save changes
        if (event.getAction() == InventoryAction.NOTHING) {
            return;
        }

        BackpackUpdater.update(inventory, InventoryManager.get(player).getBackpack());
    } else if ((event.getRawSlot() >= event.getView().getTopInventory().getSize()
            || event.getSlot() == SlotManager.instance().getBackpackSlot().getSlotId()
                    && InventoryAPI.isRPGInventory(event.getInventory()))
            && !BackpackManager.playerCanTakeBackpack(player)
            && BackpackManager.isBackpack(event.getCursor())
            && ActionType.getTypeOfAction(event.getAction()) == ActionType.SET) {
        // Prevent placing new backpack in bottom inventory if player can't take backpack
        int limit = BackpackManager.getLimit();
        String message = RPGInventory.getLanguage().getMessage("backpack.limit", limit);
        PlayerUtils.sendMessage(player, message);
        event.setCancelled(true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:39,代码来源:BackpackListener.java

示例15: onCheckSetPlayerInventory

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onCheckSetPlayerInventory(InventoryClickEvent event){
	Inventory inventory = event.getInventory();
	String inventoryName = inventory.getName();
	ItemStack item = event.getCurrentItem();
	if(inventoryName.contains(Message.getMsg("setPlayerGui.guiName").replace("{0}",""))){
		Player admin = (Player) event.getView().getPlayer();
		if(item != null&&!item.getType().equals(Material.AIR)){
			String player = inventory.getItem(4).getItemMeta().getDisplayName().replace("§4§l", "");
			if(event.getRawSlot() <=26){
				//当点到PK点数时
				if(item.getItemMeta().getDisplayName().equals(Message.getMsg("setPlayerGui.wanted.Name"))){
					if(JailMap.containsKey(admin)){
						JailMap.remove(admin);
					}
					PKMap.put(admin, player);
					admin.sendMessage(Message.getMsg("admin.waitForInputMessage"));
					admin.closeInventory();
				}
				//当点到监狱时间时
				if(item.getItemMeta().getDisplayName().equals(Message.getMsg("setPlayerGui.jail.Name"))){
					if(PKMap.containsKey(admin)){
						PKMap.remove(admin);
					}
					JailMap.put(admin, player);
					admin.sendMessage(Message.getMsg("admin.waitForInputMessage"));
					admin.closeInventory();
				}
				//当点到通缉目标时
				if(item.getItemMeta().getDisplayName().equals(Message.getMsg("setPlayerGui.asWanted.Name"))){
					YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player);
					if(!PlayerData.getString("asWanted.target").equals("N/A")){
						PlayerData.set("asWanted.target", String.valueOf("N/A"));
						PVPAsWantedManager.onSaveData(player, PlayerData);
						openSetPlayerGui(admin,player);
					}else{
						openSetPlayerGui(admin,player);
					}
				}
				//当点到退出菜单时
				if(item.getItemMeta().getDisplayName().equals(Message.getMsg("asWantedGui.quit"))){
					admin.closeInventory();
				}
			}
		}
		event.setCancelled(true);
	}
}
 
开发者ID:Saukiya,项目名称:PVPAsWantedManager,代码行数:49,代码来源:InventoryManager.java


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