/** * Gets the level of the specified enchantment on this item stack * * @param ench Enchantment to check * @return Level of the enchantment, or 0 */ public int getEnchantmentLevel(Enchantment ench) { return meta == null ? 0 : meta.getEnchantLevel(ench); }
/** * Gets the level of the specified enchantment on this item stack * * @param ench Enchantment to check * @return Level of the enchantment, or 0 */ public int getEnchantmentLevel(Enchantment ench) { return meta == null ? 0 : meta.getEnchantLevel(ench); }
/** * 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; }