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;
}
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;
}
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;
}
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;
}
use of org.bukkit.enchantments.Enchantment in project Essentials by drtshock.
the class EssentialsConf method getItemStack.
@Override
public ItemStack getItemStack(final String path) {
final ItemStack stack = new ItemStack(Material.valueOf(getString(path + ".type", "AIR")), getInt(path + ".amount", 1), (short) getInt(path + ".damage", 0));
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
if (enchants != null) {
for (String enchant : enchants.getKeys(false)) {
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
if (enchantment == null) {
continue;
}
final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel());
stack.addUnsafeEnchantment(enchantment, level);
}
}
return stack;
/*
* ,
* (byte)getInt(path + ".data", 0)
*/
}
Aggregations