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


Java InventoryClickEvent.getView方法代码示例

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


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

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

示例2: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    UUID uuid = event.getWhoClicked().getUniqueId();
    if (invClickables.containsKey(uuid)) {
        HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
        String invName = event.getInventory().getName();
        if (invName != null && invs.containsKey(invName) && event.getCurrentItem() != null) {
            event.setCancelled(true);
            ((Player) event.getWhoClicked()).updateInventory();
            ItemStack item = event.getCurrentItem();
            String serialized = serializeForMenu(item);
            //                System.out.println("checking " + invs.get(invName) + " for " + serialized);
            if (invs.get(invName).containsKey(serialized)) {
                Runnable r = invs.get(invName).get(serialized);
                r.run();
            }
        }
    }
    if (event.getView() != null && event.getView().getBottomInventory() != null && event.getView().getBottomInventory() instanceof CraftInventoryPlayer) {
        if (event.getRawSlot() >= event.getView().getTopInventory().getSize() && generalClickables.containsKey(uuid)) {
            Player p = (Player) event.getWhoClicked();
            generalClickables.get(uuid).onClick(p, event.getCurrentItem(), event.getSlot());
        }
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaCore,代码行数:26,代码来源:MenuManager.java

示例3: convert

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
private InventoryClickEvent convert(InventoryClickEvent event) {
    int rawSlot = event.getRawSlot();
    int convertedSlot = rawSlot - 9 + (currPage * spaceSize);
    return new InventoryClickEvent(
            event.getView(), event.getSlotType(), convertedSlot,
            event.getClick(), event.getAction(), event.getHotbarButton()
    );
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:9,代码来源:PageGUI.java

示例4: GUIClickEvent

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
public GUIClickEvent(InventoryClickEvent delegate, GUI gui) {
    super(delegate.getView(), delegate.getSlotType(), delegate.getRawSlot(), delegate.getClick(), delegate.getAction(), delegate.getHotbarButton());
    this.delegate = delegate;
    this.gui = gui;
    this.rawSlot = delegate.getRawSlot();
    this.slot = delegate.getSlot();
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:8,代码来源:GUIClickEvent.java

示例5: onInventoryClick

import org.bukkit.event.inventory.InventoryClickEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
	Inventory inv = e.getInventory();
		 
	if(inv instanceof AnvilInventory)
	{
		AnvilInventory anvil = (AnvilInventory)inv;
		InventoryView view = e.getView();
		int rawSlot = e.getRawSlot();
		 
		// compare raw slot to the inventory view to make sure we are in the upper inventory
		if(rawSlot == view.convertSlot(rawSlot))
		{
			// 2 = result slot
			if(rawSlot == 2)
			{
				// item in the left slot
				ItemStack item = anvil.getContents()[0];
				
				if(item != null)
				{
					if
					(
						item.getType() == Material.GOLD_AXE
						|| item.getType() == Material.GOLD_PICKAXE
						|| item.getType() == Material.GOLD_SPADE
						|| item.getType() == Material.GOLD_HOE
						|| item.getType() == Material.GOLD_SWORD
						|| item.getType() == Material.WOOD_AXE
						|| item.getType() == Material.WOOD_PICKAXE
						|| item.getType() == Material.WOOD_SPADE
						|| item.getType() == Material.WOOD_HOE
						|| item.getType() == Material.WOOD_SWORD
					)
					{
						e.setCancelled(true);
						e.getWhoClicked().closeInventory();
						e.getWhoClicked().sendMessage(ChatColor.RED + Survival.Words.get("You cannot rename or repair ") + item.getItemMeta().getDisplayName() + ChatColor.RED + Survival.Words.get("period"));
					}
				}
			}
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:46,代码来源:NoAnvil.java


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