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 9e7a57a..55716be 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 @@ -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/Tier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/upgrades/Tier.kt index 6323470..12f35ad 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 @@ -10,6 +10,7 @@ import com.willfp.eco.core.recipe.recipes.ShapedCraftingRecipe import com.willfp.eco.util.StringUtils import com.willfp.ecoarmor.sets.ArmorSlot import com.willfp.ecoarmor.sets.ArmorUtils.getCrystalTier +import com.willfp.ecoarmor.util.NotNullMap import org.bukkit.inventory.ItemStack import org.bukkit.persistence.PersistentDataType import java.util.* @@ -56,7 +57,7 @@ class Tier( /** * Item properties. */ - val properties: MutableMap = EnumMap(ArmorSlot::class.java) + val properties: NotNullMap = NotNullMap(EnumMap(ArmorSlot::class.java)) /** * Create a new Tier. diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/util/NotNullMap.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/util/NotNullMap.kt new file mode 100644 index 0000000..77c6958 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoarmor/util/NotNullMap.kt @@ -0,0 +1,7 @@ +package com.willfp.ecoarmor.util + +class NotNullMap(private val handle: MutableMap) : MutableMap by handle { + override fun get(key: K): V { + return handle[key]!! + } +} \ No newline at end of file