本文整理汇总了Java中org.bukkit.inventory.ItemStack.setData方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setData方法的具体用法?Java ItemStack.setData怎么用?Java ItemStack.setData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.ItemStack
的用法示例。
在下文中一共展示了ItemStack.setData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLeftOverItems
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<? extends ItemStack> getLeftOverItems(CraftingInventory craftingInventory) {
ItemStack[] matrix = craftingInventory.getMatrix();
List<ItemStack> leftOver = new ArrayList<>(matrix.length);
for (int i = 0; i < matrix.length; i++) {
ItemStack itemStack = matrix[i];
if (InventoryUtils.isEmptyStack(itemStack)) {
leftOver.add(null);
continue;
}
ItemStack clone = itemStack.clone();
MaterialData craftingResult = InventoryUtils.getSingleIngredientResult(itemStack.getData());
if (craftingResult.getItemType() != Material.AIR) {
clone.setData(craftingResult);
leftOver.add(clone);
continue;
}
}
craftingInventory.setContents(leftOver.toArray(new ItemStack[matrix.length]));
return leftOver;
}
示例2: buildClicker
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
private static MenuGeneralRunnable<?> buildClicker(final ArrayList<ItemStack> selfItems, final TradeUpdater updater, final boolean isA) {
return new MenuGeneralRunnable<PlayerDataRPG>() {
@Override
public void execute(Player p, PlayerDataRPG pd, ItemStack item, int slot) {
if (plugin.getInstance(ItemManager.class).isSoulbound(item)) {
p.sendMessage(ChatColor.RED + "You cannot trade Soulbound items!");
return;
}
if (isA ? updater.aSlots.contains(slot) : updater.bSlots.contains(slot)) {
p.sendMessage(ChatColor.RED + "You have already offered this item.");
return;
}
if (isA)
updater.aSlots.add(slot);
else
updater.bSlots.add(slot);
ItemStack displayItem = item.clone();
displayItem.setDurability(item.getDurability());
displayItem.setData(item.getData());
ArrayList<String> lore = new ArrayList<String>();
if (item.hasItemMeta() && item.getItemMeta().hasLore())
lore.addAll(item.getItemMeta().getLore());
ItemMeta im = displayItem.getItemMeta();
lore.add("");
lore.add(ChatColor.YELLOW + "Offered by: " + ChatColor.GREEN + p.getName());
im.setLore(lore);
displayItem.setItemMeta(im);
selfItems.add(displayItem);
updater.resetStates();
updater.update();
}
};
}
示例3: build
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
/**
* Creates a new itemStack from this
*
* @return itemStack
*/
public ItemStack build() {
final ItemStack itemStack = new ItemStack(this.getType());
itemStack.setAmount(this.getAmount());
itemStack.setData(this.getData());
itemStack.setDurability(this.getDurability());
itemStack.setItemMeta(this.getItemMeta());
return itemStack;
}
示例4: build
import org.bukkit.inventory.ItemStack; //导入方法依赖的package包/类
public ItemStack build() {
ItemStack itemStack = new ItemStack(material, amount, durability);
itemProcessors.process(itemStack);
ItemMeta meta = itemStack.getItemMeta();
metaProcessors.process(meta);
itemStack.setItemMeta(meta);
itemStack.setData(data);
return itemStack;
}