Search in sources :

Example 1 with GlowEnchantment

use of net.glowstone.constants.GlowEnchantment in project Glowstone by GlowstoneMC.

the class EnchantmentManager method getAllPossibleEnchants.

private static List<LeveledEnchant> getAllPossibleEnchants(ItemStack item, int modifier, int cost) {
    List<LeveledEnchant> enchantments = new ArrayList<>();
    boolean isBook = item.getType() == Material.BOOK;
    for (Enchantment enchantment : Enchantment.values()) {
        if (isBook || enchantment.canEnchantItem(item)) {
            for (int level = enchantment.getStartLevel(); level <= enchantment.getMaxLevel(); level++) {
                if (((GlowEnchantment) enchantment).isInRange(level, modifier)) {
                    enchantments.add(new LeveledEnchant(enchantment, level, cost));
                }
            }
        }
    }
    return enchantments;
}
Also used : GlowEnchantment(net.glowstone.constants.GlowEnchantment) ArrayList(java.util.ArrayList) Enchantment(org.bukkit.enchantments.Enchantment) GlowEnchantment(net.glowstone.constants.GlowEnchantment)

Aggregations

ArrayList (java.util.ArrayList)1 GlowEnchantment (net.glowstone.constants.GlowEnchantment)1 Enchantment (org.bukkit.enchantments.Enchantment)1