本文整理汇总了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();
}