本文整理匯總了Java中org.bukkit.inventory.ItemStack.addUnsafeEnchantments方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemStack.addUnsafeEnchantments方法的具體用法?Java ItemStack.addUnsafeEnchantments怎麽用?Java ItemStack.addUnsafeEnchantments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.ItemStack
的用法示例。
在下文中一共展示了ItemStack.addUnsafeEnchantments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: build
import org.bukkit.inventory.ItemStack; //導入方法依賴的package包/類
/**
* Builds an {@link org.bukkit.inventory.ItemStack} with all the data in this ItemBuilder.
* @return The built {@link org.bukkit.inventory.ItemStack}
*/
public ItemStack build()
{
if(material == null)
throw new IllegalStateException("Cannot build ItemStack with null material");
if(amount < 1)
throw new IllegalStateException("Cannot build ItemStack with amount less than 1");
ItemStack item = new ItemStack(material, amount, (short)metadata);
// ItemStack item = CraftItemStack.asCraftCopy(new ItemStack(material, amount, (short)metadata));
if(enchantments != null)
item.addUnsafeEnchantments(enchantments);
if(name != null || lore != null || (flags != null && !flags.isEmpty()))
{
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(name);
meta.setLore(lore);
if(flags != null)
flags.forEach(meta::addItemFlags);
item.setItemMeta(meta);
}
return item;
}