当前位置: 首页>>代码示例>>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;未经允许,请勿转载。