本文整理汇总了Java中org.bukkit.enchantments.Enchantment.getStartLevel方法的典型用法代码示例。如果您正苦于以下问题:Java Enchantment.getStartLevel方法的具体用法?Java Enchantment.getStartLevel怎么用?Java Enchantment.getStartLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.enchantments.Enchantment
的用法示例。
在下文中一共展示了Enchantment.getStartLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}