本文整理匯總了Java中org.bukkit.inventory.meta.EnchantmentStorageMeta.getStoredEnchantLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java EnchantmentStorageMeta.getStoredEnchantLevel方法的具體用法?Java EnchantmentStorageMeta.getStoredEnchantLevel怎麽用?Java EnchantmentStorageMeta.getStoredEnchantLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.EnchantmentStorageMeta
的用法示例。
在下文中一共展示了EnchantmentStorageMeta.getStoredEnchantLevel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
@Override
@Nullable
protected Integer[] get(Event event) {
ItemStack input = book.getSingle(event);
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) input.getItemMeta();
return new Integer[]{meta.getStoredEnchantLevel(enchant.getSingle(event).getType())};
}
示例2: change
import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
public void change(Event event, Object[] delta, Changer.ChangeMode mode){
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) book.getSingle(event).getItemMeta();
Enchantment ench = enchant.getSingle(event).getType();
Integer level = meta.getStoredEnchantLevel(ench);
Logging.info("Initial level: " + level);
if (meta.hasStoredEnchant(ench)) meta.removeStoredEnchant(ench);
if (mode == ChangeMode.SET) level = ((Number) delta[0]).intValue();
if (mode == ChangeMode.ADD) level += ((Number) delta[0]).intValue();
if (mode == ChangeMode.REMOVE) level -= ((Number) delta[0]).intValue();
Logging.info("New level: " + level);
if (level > 0) meta.addStoredEnchant(ench, level, true);
book.getSingle(event).setItemMeta(meta);
}
示例3: validateCrafting
import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
@Override
public boolean validateCrafting(CraftingInventory inventory) {
for (ItemStack stack : inventory.getMatrix()) {
if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) stack.getItemMeta();
if (meta.getStoredEnchantLevel(Enchantment.SILK_TOUCH) < 1) {
return false;
}
}
}
return true;
}
示例4: isSimilar
import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
public boolean isSimilar(ItemStack item) {
if(item == null) return false;
if (mat == Material.ENCHANTED_BOOK && item.getType() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta enchantMeta = (EnchantmentStorageMeta)item.getItemMeta();
if(enchantMeta.getStoredEnchants().size() == 1)
{
Enchantment itemEnch = enchantMeta.getStoredEnchants().keySet().toArray(new Enchantment[0])[0];
if (itemEnch == ench && enchantMeta.getStoredEnchantLevel(itemEnch) == damage) return true;
}
return false;
}
return getContents().isSimilar(item);
}