本文整理匯總了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;
}