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


Java InventoryView.setItem方法代碼示例

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


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

示例1: update

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
public void update(Player player) {
	InventoryView inventory = player.getOpenInventory();
	if (inventory != null) {
        for (int iii = 0; iii < this.optionIcons.length; iii++) {
            if (this.optionIcons[iii] != null) {
                inventory.setItem(iii, this.optionIcons[iii]);
            }
        }
        player.updateInventory();
	}
}
 
開發者ID:smessie,項目名稱:SkyWarsReloaded,代碼行數:12,代碼來源:IconMenu.java

示例2: onItemClick

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onItemClick(InventoryClickEvent inventoryClickEvent) {
    Player player = (Player) inventoryClickEvent.getWhoClicked();

    InventoryView inventory = player.getOpenInventory();
    if (plugin.getConfig().getBoolean("inventoryPin") && inventory != null
            && "Pin code".equals(inventory.getTitle())) {
        if (inventoryClickEvent.getRawSlot() < 36) {
            Inventory clickedInventory = inventoryClickEvent.getClickedInventory();
            ItemStack currentItem = inventoryClickEvent.getCurrentItem();
            if (currentItem != null) {
                switch (currentItem.getType()) {
                    case STONE:
                        int nextPos = nextPinPos(clickedInventory);
                        if (nextPos != -1) {
                            inventory.setItem(nextPos, currentItem);
                        }
                        break;
                    case BARRIER:
                        player.closeInventory();
                        break;
                    case REDSTONE_BLOCK:
                        deleteLast(inventory);
                        break;
                    case SLIME_BALL:
                        submitPin((Player) inventoryClickEvent.getWhoClicked(), clickedInventory);
                        break;
                    default:
                        break;
                }
            }
        }

        inventoryClickEvent.setCancelled(true);
    }
}
 
開發者ID:games647,項目名稱:SecureMyAccount,代碼行數:37,代碼來源:InventoryPinListener.java

示例3: deleteLast

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
private void deleteLast(InventoryView inventory) {
    for (int i = 34; i > 28; i--) {
        ItemStack item = inventory.getItem(i);
        if (item != null) {
            inventory.setItem(i, null);
            break;
        }
    }
}
 
開發者ID:games647,項目名稱:SecureMyAccount,代碼行數:10,代碼來源:InventoryPinListener.java

示例4: setItem

import org.bukkit.inventory.InventoryView; //導入方法依賴的package包/類
@Override
public void setItem(PlotInventory inv, int index, PlotItemStack item) {
    BukkitPlayer bp = ((BukkitPlayer) inv.player);
    InventoryView opened = bp.player.getOpenInventory();
    if (!inv.isOpen()) {
        return;
    }
    opened.setItem(index, getItem(item));
    bp.player.updateInventory();
}
 
開發者ID:Mayomi,項目名稱:PlotSquared-Chinese,代碼行數:11,代碼來源:BukkitInventoryUtil.java


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