/** * Checks if this ItemStack contains the given {@link Enchantment} * * @param ench Enchantment to test * @return True if this has the given enchantment */ public boolean containsEnchantment(Enchantment ench) { return meta == null ? false : meta.hasEnchant(ench); }
/** * Checks if this ItemStack contains the given {@link Enchantment} * * @param ench Enchantment to test * @return True if this has the given enchantment */ public boolean containsEnchantment(Enchantment ench) { return meta == null ? false : meta.hasEnchant(ench); }
public static void removeGlow(ItemStack stack) { if (NMSUtils.isEmpty(stack)) return; try { ItemMeta meta = stack.getItemMeta(); if (meta.hasEnchant(Enchantment.LUCK)) { meta.removeEnchant(Enchantment.LUCK); stack.setItemMeta(meta); } } catch (Throwable ex) { ex.printStackTrace(); } }
/** * Gets the NPC's current damage value (based on held weapon if calculation is required). */ public double getDamage() { if (damage >= 0) { return damage; } ItemStack weapon = itemHelper.getHeldItem(); if (weapon == null) { return 1; } // TODO: Less randomness, more game-like calculations. double multiplier = 1; multiplier += weapon.getItemMeta() == null || !weapon.getItemMeta().hasEnchant(Enchantment.DAMAGE_ALL) ? 0 : weapon.getItemMeta().getEnchantLevel(Enchantment.DAMAGE_ALL) * 0.2; Material weaponType = weapon.getType(); if (SentinelTarget.BOW_MATERIALS.contains(weaponType)) { return 6 * (1 + (weapon.getItemMeta() == null || !weapon.getItemMeta().hasEnchant(Enchantment.ARROW_DAMAGE) ? 0 : weapon.getItemMeta().getEnchantLevel(Enchantment.ARROW_DAMAGE) * 0.3)); } Double damageMult = SentinelTarget.WEAPON_DAMAGE_MULTIPLIERS.get(weaponType); if (damageMult == null) { return multiplier; } return multiplier * damageMult; }
if (!itemMeta.hasEnchant(enchantment)) { player.sendMessage(api.getMessages().get("item.no_enchant").replace("$enchant", enchantment.getName())); } else {