当前位置: 首页>>代码示例>>Java>>正文


Java Enchantment.getMaxLevel方法代码示例

本文整理汇总了Java中org.bukkit.enchantments.Enchantment.getMaxLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Enchantment.getMaxLevel方法的具体用法?Java Enchantment.getMaxLevel怎么用?Java Enchantment.getMaxLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.enchantments.Enchantment的用法示例。


在下文中一共展示了Enchantment.getMaxLevel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.bukkit.enchantments.Enchantment; //导入方法依赖的package包/类
public void run(WCUser user, String label, String[] args){
    if (args.length == 2){
        boolean unsafe = plugin.getConfig().getBoolean("allowUnsafeEnchantment");
        ItemStack i = user.getPlayer().getInventory().getItemInMainHand();

        Enchantment enchantment;
        int level;

        if (!Utils.isInt(args[1])) return;
        enchantment = getEnchantment(args[0]);
        level = Integer.parseInt(args[1]);

        if (enchantment == null) return;

        if (unsafe){
            i.addUnsafeEnchantment(enchantment, level);
            return;
        }
        if (level > enchantment.getMaxLevel()) return;

        i.addEnchantment(enchantment, level);
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:24,代码来源:EnchantCMD.java

示例2: getRandomEnchant

import org.bukkit.enchantments.Enchantment; //导入方法依赖的package包/类
public static ItemStack getRandomEnchant(List<Enchantment>enchants, int amount){
	ItemStack result = new ItemStack(Material.ENCHANTED_BOOK);
	List<Enchantment>left = new ArrayList<Enchantment>(enchants);
	EnchantmentStorageMeta meta = (EnchantmentStorageMeta) result.getItemMeta();
	if(amount > left.size())
		amount = left.size();
	for(int i = 0 ; i < amount && !left.isEmpty() ; i++){
		Enchantment e = VanillaPlusCore.getRandom(left);
		left.remove(e);
		int level = VanillaPlusCore.getRandom().nextInt(100);
		level = level % (e.getMaxLevel()+1-e.getStartLevel())+e.getStartLevel();
		meta.addStoredEnchant(e, level, false);
	}
	result.setItemMeta(meta);
	return result;
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:17,代码来源:MinecraftUtils.java

示例3: addStoredEnchant

import org.bukkit.enchantments.Enchantment; //导入方法依赖的package包/类
public boolean addStoredEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
    if (enchantments == null) {
        enchantments = new HashMap<Enchantment, Integer>(4);
    }

    if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
        Integer old = enchantments.put(ench, level);
        return old == null || old != level;
    }
    return false;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftMetaEnchantedBook.java

示例4: addEnchant

import org.bukkit.enchantments.Enchantment; //导入方法依赖的package包/类
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
    if (enchantments == null) {
        enchantments = new HashMap<Enchantment, Integer>(4);
    }

    if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
        Integer old = enchantments.put(ench, level);
        return old == null || old != level;
    }
    return false;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:12,代码来源:CraftMetaItem.java


注:本文中的org.bukkit.enchantments.Enchantment.getMaxLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。