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


Java Inventory.getType方法代碼示例

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


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

示例1: CraftContainer

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
public CraftContainer(final Inventory inventory, final HumanEntity player, int id) {
    this(new InventoryView() {
        @Override
        public Inventory getTopInventory() {
            return inventory;
        }

        @Override
        public Inventory getBottomInventory() {
            return player.getInventory();
        }

        @Override
        public HumanEntity getPlayer() {
            return player;
        }

        @Override
        public InventoryType getType() {
            return inventory.getType();
        }
    }, id);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:24,代碼來源:CraftContainer.java

示例2: rowType

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
public static boolean rowType(Integer row, Integer slot, Inventory inventory) {
	if (slot != null && row != null) {
		Integer mod = 9;
		if (inventory != null) {
			if (inventory.getType() == InventoryType.DISPENSER ||inventory.getType() == InventoryType.WORKBENCH || inventory.getType() == InventoryType.DROPPER) {
				mod = 3;
			} else if (inventory.getType() == InventoryType.CHEST || inventory.getType() == InventoryType.ENDER_CHEST || inventory.getType() == InventoryType.PLAYER){
				mod = 9;
			} else {
				mod = inventory.getSize();
			}
		}
		Integer calculate = row * mod;
		return slot >= calculate - mod && slot < calculate;
	}
	return false;
}
 
開發者ID:WheezyGold7931,項目名稱:skLib,代碼行數:18,代碼來源:ExprClickedRow.java

示例3: GUIMaker

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
public GUIMaker(Inventory inv) {
	if (inv.getType() == InventoryType.CHEST) { // 自定義大小的 Inventory
		this.inv = Bukkit.createInventory(inv.getHolder(), inv.getSize(), inv.getTitle());
	} else { // 自定義類型的 Inventory
		this.inv = Bukkit.createInventory(inv.getHolder(), inv.getType(), inv.getTitle());
	}
	this.inv.setContents(inv.getContents());
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:9,代碼來源:GUIMaker.java

示例4: onInventoryDrag

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {
    Player player = (Player) event.getWhoClicked();

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

    for (Integer rawSlotId : event.getRawSlots()) {
        ItemStack cursor = event.getOldCursor();
        Inventory inventory = event.getInventory();

        if (PetManager.isPetItem(cursor)) {
            event.setCancelled(true);
            return;
        }

        if (inventory.getType() == InventoryType.CRAFTING) {
            if (InventoryManager.get(player).isOpened()) {
                return;
            }

            // Shield slot is QUICKBAR and has rawId - 45 o.O
            if (rawSlotId >= 1 && rawSlotId <= 8 || rawSlotId == 45) {
                event.setCancelled(true);
                return;
            }
        } else if (InventoryAPI.isRPGInventory(inventory)) {
            if (rawSlotId < 54) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:36,代碼來源:InventoryListener.java

示例5: refresh

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
public void refresh(VPPlayer viewer) {
	if(viewer.getMenu() != null)
		viewer.getMenu().refresh(viewer, viewer.getPlayer().getInventory());
	Inventory inv = viewer.getPlayer().getOpenInventory().getTopInventory();
	if(inv == null || inv.getType() == InventoryType.CRAFTING) {
		return;
	}
	if (inv.getHolder() instanceof MenuLink)
		((MenuLink) inv.getHolder()).getIconMenu().refresh(viewer, inv);
}
 
開發者ID:dracnis,項目名稱:VanillaPlus,代碼行數:11,代碼來源:MenuManager.java

示例6: onBreakWorkbench

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
	if(e.isCancelled()) return;
	Block workbench = e.getBlock();

	if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
		return;
	
	@SuppressWarnings("unchecked")
	List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
	
	Iterator<UUID> iterator = list.iterator();
	
	Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
	
	while (iterator.hasNext())
	{
		UUID next = iterator.next();
		
		iterator.remove();
		
		final Player idPlayer = Bukkit.getPlayer(next);
		
		if (idPlayer != null)
		{
			idPlayer.removeMetadata("shared_inv", Survival.instance);
			
			if(idPlayer.isOnline())
			{
				final Inventory open = idPlayer.getOpenInventory().getTopInventory();
				
				if (open != null && open.getType() == InventoryType.WORKBENCH)
				{
					sharedInventory.setContents(open.getContents());
					open.clear();
					idPlayer.closeInventory();
				}
			}
		}
	}
	
	for(int i = 1; i < sharedInventory.getSize(); i++)
	{
		ItemStack item = sharedInventory.getItem(i);
		if(item != null)
			workbench.getWorld().dropItem(workbench.getLocation(), item);
	}
	
	workbench.removeMetadata("shared_players", Survival.instance);
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:52,代碼來源:WorkbenchShare.java

示例7: ensureOurInventory

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
private boolean ensureOurInventory(Inventory inventory) {
    return inventory.getName().equals(this.inventory.getName()) && inventory.getType() == this.inventory.getType() && inventory.getViewers().equals(this.inventory.getViewers());
}
 
開發者ID:shawlaf,項目名稱:Banmanager,代碼行數:4,代碼來源:UserInterface.java

示例8: isSimilar

import org.bukkit.inventory.Inventory; //導入方法依賴的package包/類
public boolean isSimilar(Inventory inv) {
    return inv != null &&
            getType() == inv.getType() &&
            getTitle().equals(inv.getTitle()) &&
            getSize() == inv.getSize();
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:7,代碼來源:GUISignature.java


注:本文中的org.bukkit.inventory.Inventory.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。