From 50986288b07ad366205a493d1633ae94eef4e81f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 17 Dec 2021 13:00:24 +0000 Subject: [PATCH] Fixed various errors --- .../com/willfp/ecoarmor/sets/ArmorSet.kt | 6 +++--- .../com/willfp/ecoarmor/sets/ArmorUtils.kt | 18 +++++++++--------- .../ecoarmor/upgrades/CrystalListener.kt | 2 +- .../com/willfp/ecoarmor/upgrades/Tier.kt | 3 ++- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSet.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSet.kt index fe7da1f..bef3461 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSet.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorSet.kt @@ -219,9 +219,9 @@ class ArmorSet( ) { if (slotConfig.getBool("craftable")) { val formattedOut = out.clone() - val meta = formattedOut.itemMeta!! - assert(meta.lore != null) - val lore = meta.lore.map { it.replace("%tier%", Tiers.defaultTier.displayName) } + val meta = formattedOut.itemMeta ?: return + val metaLore = meta.lore ?: emptyList() + val lore = metaLore.map { it.replace("%tier%", Tiers.defaultTier.displayName) } meta.lore = lore formattedOut.itemMeta = meta Recipes.createAndRegisterRecipe( diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorUtils.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorUtils.kt index 53c1eff..9e7a57a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorUtils.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/sets/ArmorUtils.kt @@ -143,8 +143,8 @@ object ArmorUtils { val meta = itemStack.itemMeta ?: return null val tier = getTier(meta) return if (getSetOnItem(meta) != null && tier == null) { - setTier(itemStack, Tiers.getDefaultTier()) - Tiers.getDefaultTier() + setTier(itemStack, Tiers.defaultTier) + Tiers.defaultTier } else { tier } @@ -202,13 +202,13 @@ object ArmorUtils { tier.id ) val slot = getSlot(itemStack) ?: return - val armor = tier.properties[slot]!!.armor() - val toughness = tier.properties[slot]!!.toughness() - val knockback = tier.properties[slot]!!.knockback() - val speed = tier.properties[slot]!!.speed() - val attackSpeed = tier.properties[slot]!!.attackSpeed() - val attackDamage = tier.properties[slot]!!.attackDamage() - val attackKnockback = tier.properties[slot]!!.attackKnockback() + val armor = tier.properties[slot]!!.armor + val toughness = tier.properties[slot]!!.toughness + val knockback = tier.properties[slot]!!.knockback + val speed = tier.properties[slot]!!.speed + val attackSpeed = tier.properties[slot]!!.attackSpeed + val attackDamage = tier.properties[slot]!!.attackDamage + val attackKnockback = tier.properties[slot]!!.attackKnockback meta.removeAttributeModifier(Attribute.GENERIC_ARMOR) meta.removeAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS) meta.removeAttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/CrystalListener.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/CrystalListener.kt index 5d1c231..8c91fde 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/CrystalListener.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/CrystalListener.kt @@ -30,7 +30,7 @@ class CrystalListener(private val plugin: EcoPlugin) : Listener { } val previousTier = ArmorUtils.getTier(current) var allowed = false - val prereq = crystalTier.requiredTiersForApplication + val prereq = crystalTier.getRequiredTiersForApplication() if (prereq.isEmpty() || prereq.contains(previousTier)) { allowed = true } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt index 21745a4..6323470 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt @@ -75,7 +75,8 @@ class Tier( val outMeta = out.itemMeta!! val container = outMeta.persistentDataContainer container.set(key, PersistentDataType.STRING, id) - outMeta.displayName = this.config.getString("crystal.name") + @Suppress("UsePropertyAccessSyntax") + outMeta.setDisplayName(this.config.getString("crystal.name")) val lore: MutableList = ArrayList() for (loreLine in this.config.getStrings("crystal.lore")) { lore.add(Display.PREFIX + StringUtils.format(loreLine!!))