本文整理匯總了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();
}
}
示例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);
}
}
示例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;
}
}
}
示例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();
}