本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}