add unit repair to item config

This commit is contained in:
alexcrea 2026-07-01 13:21:18 +02:00
parent 6178282386
commit bc9ac1cc13
Signed by: alexcrea
GPG key ID: E59DF23EE2A2266C
3 changed files with 22 additions and 9 deletions

View file

@ -25,7 +25,7 @@ object UnitRepairUtil {
if (other == null) return null
val config = ConfigHolder.UNIT_REPAIR_HOLDER.config
val result = findRepairValue(this, other, config) ?: return null
val result = findRawRepairValue(this, other, config) ?: return null
if(result > 0) return result
@ -36,7 +36,7 @@ object UnitRepairUtil {
return userDefault
}
private fun findRepairValue(
private fun findRawRepairValue(
self: ItemStack,
other: ItemStack,
config: FileConfiguration
@ -50,6 +50,17 @@ object UnitRepairUtil {
return checkSection(config, material.key, selfType)
}
fun findRawRepairValue(
self: NamespacedKey,
other: NamespacedKey,
config: FileConfiguration
): Double? {
val result = checkSection(config, other.toString(), self)
if (result != null) return result
return checkSection(config, other.key, self)
}
fun checkSection(
config: FileConfiguration,
path: String,