當前位置: 首頁>>代碼示例>>Java>>正文


Java InventoryView.convertSlot方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.InventoryView.convertSlot方法的典型用法代碼示例。如果您正苦於以下問題:Java InventoryView.convertSlot方法的具體用法?Java InventoryView.convertSlot怎麽用?Java InventoryView.convertSlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.InventoryView的用法示例。


在下文中一共展示了InventoryView.convertSlot方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onRepair

import org.bukkit.inventory.InventoryView; //導入方法依賴的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: fromViewIndex

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
public static InventorySlot<?> fromViewIndex(InventoryView view, int rawIndex) {
    final Slot slot = Slot.forViewIndex(view, rawIndex);
    if(slot == null) {
        throw new IllegalArgumentException("Could not determine slot at index " + rawIndex + " in view " + view);
    }
    final Inventory inventory = rawIndex == view.convertSlot(rawIndex) ? view.getTopInventory()
                                                                       : view.getBottomInventory();
    return new InventorySlot<>(inventory, slot);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:10,代碼來源:InventorySlot.java

示例3: InventoryClickEvent

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
public InventoryClickEvent(InventoryView view, SlotType type, int slot, ClickType click, InventoryAction action) {
    super(view);
    this.slot_type = type;
    this.rawSlot = slot;
    this.whichSlot = view.convertSlot(slot);
    this.click = click;
    this.action = action;
}
 
開發者ID:CyberdyneCC,項目名稱:Thermos-Bukkit,代碼行數:9,代碼來源:InventoryClickEvent.java

示例4: forViewIndex

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
public static @Nullable Slot<?, ?> forViewIndex(InventoryView view, int rawIndex) {
    final int cookedIndex = view.convertSlot(rawIndex);
    return forInventoryIndex((rawIndex == cookedIndex ? view.getTopInventory()
                                                      : view.getBottomInventory()).getClass(),
                             cookedIndex);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:7,代碼來源:Slot.java

示例5: onInventoryClick

import org.bukkit.inventory.InventoryView; //導入方法依賴的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.inventory.InventoryView.convertSlot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。