Search in sources :

Example 36 with Enchantment

use of org.bukkit.enchantments.Enchantment in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareEnchantments.

public static boolean compareEnchantments(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.getEnchantments().size() == i2.getEnchantments().size()) {
        Map<Enchantment, Integer> e1 = i1.getEnchantments();
        Map<Enchantment, Integer> e2 = i2.getEnchantments();
        Enchantment[] e1l = new Enchantment[e1.size()];
        int i = 0;
        for (Enchantment enchantment : e1.keySet()) {
            e1l[i++] = enchantment;
        }
        i = 0;
        for (Enchantment enchantment : e2.keySet()) {
            if (e1l[i].getId() != enchantment.getId()) {
                // MyPetLogger.write("enchantment: " + e1l[i].getId() + "<->" + enchantment.getId());
                return false;
            } else if (!e1.get(e1l[i]).equals(e2.get(enchantment))) {
                // MyPetLogger.write("level: " + e1.get(e1l[i]) + "<->" + e2.get(enchantment));
                return false;
            }
            i++;
        }
        return true;
    }
    // MyPetLogger.write("size: " + i1.getEnchantments().size() + "<->" + i2.getEnchantments().size());
    return false;
}
Also used : Enchantment(org.bukkit.enchantments.Enchantment)

Example 37 with Enchantment

use of org.bukkit.enchantments.Enchantment in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareEnchantments.

public static boolean compareEnchantments(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.getEnchantments().size() == i2.getEnchantments().size()) {
        Map<Enchantment, Integer> e1 = i1.getEnchantments();
        Map<Enchantment, Integer> e2 = i2.getEnchantments();
        Enchantment[] e1l = new Enchantment[e1.size()];
        int i = 0;
        for (Enchantment enchantment : e1.keySet()) {
            e1l[i++] = enchantment;
        }
        i = 0;
        for (Enchantment enchantment : e2.keySet()) {
            if (e1l[i].getId() != enchantment.getId()) {
                // MyPetLogger.write("enchantment: " + e1l[i].getId() + "<->" + enchantment.getId());
                return false;
            } else if (!e1.get(e1l[i]).equals(e2.get(enchantment))) {
                // MyPetLogger.write("level: " + e1.get(e1l[i]) + "<->" + e2.get(enchantment));
                return false;
            }
            i++;
        }
        return true;
    }
    // MyPetLogger.write("size: " + i1.getEnchantments().size() + "<->" + i2.getEnchantments().size());
    return false;
}
Also used : Enchantment(org.bukkit.enchantments.Enchantment)

Example 38 with Enchantment

use of org.bukkit.enchantments.Enchantment in project MyPet by xXKeyleXx.

the class ItemStackComparator method compareEnchantments.

public static boolean compareEnchantments(ItemStack i1, ItemStack i2) {
    if (i1 == null || i2 == null) {
        return false;
    }
    if (i1.getEnchantments().size() == i2.getEnchantments().size()) {
        Map<Enchantment, Integer> e1 = i1.getEnchantments();
        Map<Enchantment, Integer> e2 = i2.getEnchantments();
        Enchantment[] e1l = new Enchantment[e1.size()];
        int i = 0;
        for (Enchantment enchantment : e1.keySet()) {
            e1l[i++] = enchantment;
        }
        i = 0;
        for (Enchantment enchantment : e2.keySet()) {
            if (e1l[i].getId() != enchantment.getId()) {
                // MyPetLogger.write("enchantment: " + e1l[i].getId() + "<->" + enchantment.getId());
                return false;
            } else if (!e1.get(e1l[i]).equals(e2.get(enchantment))) {
                // MyPetLogger.write("level: " + e1.get(e1l[i]) + "<->" + e2.get(enchantment));
                return false;
            }
            i++;
        }
        return true;
    }
    // MyPetLogger.write("size: " + i1.getEnchantments().size() + "<->" + i2.getEnchantments().size());
    return false;
}
Also used : Enchantment(org.bukkit.enchantments.Enchantment)

Aggregations

Enchantment (org.bukkit.enchantments.Enchantment)38 ItemStack (org.bukkit.inventory.ItemStack)16 EnchantmentStorageMeta (org.bukkit.inventory.meta.EnchantmentStorageMeta)5 ItemMeta (org.bukkit.inventory.meta.ItemMeta)5 Map (java.util.Map)4 GlowEnchantment (net.glowstone.constants.GlowEnchantment)3 Entry (java.util.Map.Entry)2 CompoundTag (net.glowstone.util.nbt.CompoundTag)2 Color (org.bukkit.Color)2 FireworkEffect (org.bukkit.FireworkEffect)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)2 BookMeta (org.bukkit.inventory.meta.BookMeta)2 FireworkEffectMeta (org.bukkit.inventory.meta.FireworkEffectMeta)2 LeatherArmorMeta (org.bukkit.inventory.meta.LeatherArmorMeta)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)2 PotionEffect (org.bukkit.potion.PotionEffect)2 ChargeException (com.earth2me.essentials.ChargeException)1 MetaItemStack (com.earth2me.essentials.MetaItemStack)1 Trade (com.earth2me.essentials.Trade)1 ImmutableMap (com.google.common.collect.ImmutableMap)1