當前位置: 首頁>>代碼示例>>Java>>正文


Java EnchantmentStorageMeta.removeStoredEnchant方法代碼示例

本文整理匯總了Java中org.bukkit.inventory.meta.EnchantmentStorageMeta.removeStoredEnchant方法的典型用法代碼示例。如果您正苦於以下問題:Java EnchantmentStorageMeta.removeStoredEnchant方法的具體用法?Java EnchantmentStorageMeta.removeStoredEnchant怎麽用?Java EnchantmentStorageMeta.removeStoredEnchant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.inventory.meta.EnchantmentStorageMeta的用法示例。


在下文中一共展示了EnchantmentStorageMeta.removeStoredEnchant方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerInteract

import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.hasItem()) {
        // The player didn't click an enchantment table, Creative players will instantly destroy.
        Player player = event.getPlayer();
        if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && player.getGameMode() != GameMode.CREATIVE) {

            // The player didn't click with an enchanted book.
            ItemStack stack = event.getItem();
            if (stack != null && stack.getType() == Material.ENCHANTED_BOOK) {
                ItemMeta meta = stack.getItemMeta();
                if (meta instanceof EnchantmentStorageMeta) {
                    EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) meta;
                    for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
                        enchantmentStorageMeta.removeStoredEnchant(enchantment);
                    }

                    event.setCancelled(true);
                    player.setItemInHand(EMPTY_BOOK);
                    player.sendMessage(ChatColor.GREEN + "You reverted this item to its original form.");
                }
            }
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:26,代碼來源:BookDeenchantListener.java

示例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);
}
 
開發者ID:MundoSK,項目名稱:MundoSK,代碼行數:14,代碼來源:ExprEnchantLevelInEnchBook.java

示例3: removeFromItem

import org.bukkit.inventory.meta.EnchantmentStorageMeta; //導入方法依賴的package包/類
@Override
public ItemStack removeFromItem(final ItemStack item) {
    if (item.getType() == Material.ENCHANTED_BOOK) {
        final EnchantmentStorageMeta meta = (EnchantmentStorageMeta)item.getItemMeta();
        meta.removeStoredEnchant(enchantment);
        item.setItemMeta(meta);
    }
    item.removeEnchantment(enchantment);
    return item;
}
 
開發者ID:Eniripsa96,項目名稱:EnchantmentAPI,代碼行數:11,代碼來源:VanillaEnchantment.java


注:本文中的org.bukkit.inventory.meta.EnchantmentStorageMeta.removeStoredEnchant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。