9
0
mirror of https://github.com/Auxilor/EcoArmor.git synced 2025-12-27 02:49:22 +00:00

Added NotNullMap

This commit is contained in:
Auxilor
2021-12-17 15:21:35 +00:00
parent f2dfefa093
commit 40e3de3d44
3 changed files with 16 additions and 8 deletions

View File

@@ -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)

View File

@@ -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<ArmorSlot, TierProperties> = EnumMap(ArmorSlot::class.java)
val properties: NotNullMap<ArmorSlot, TierProperties> = NotNullMap(EnumMap(ArmorSlot::class.java))
/**
* Create a new Tier.

View File

@@ -0,0 +1,7 @@
package com.willfp.ecoarmor.util
class NotNullMap<K, V>(private val handle: MutableMap<K, V>) : MutableMap<K, V> by handle {
override fun get(key: K): V {
return handle[key]!!
}
}