Made unit repair test lower first.

Default config and creation use lowercase by default. testing lowercase first is a small improvement of performances.
This commit is contained in:
alexcrea 2024-07-24 02:16:40 +02:00
parent b53d347221
commit e43f6276cd
No known key found for this signature in database
GPG key ID: 43FD265DB0DBF91F

View file

@ -22,10 +22,10 @@ object UnitRepairUtil {
if (other == null) return null if (other == null) return null
val config = ConfigHolder.UNIT_REPAIR_HOLDER.config val config = ConfigHolder.UNIT_REPAIR_HOLDER.config
// Get configuration section if exist // Get configuration section if exist
val otherName = other.type.name.uppercase() val otherName = other.type.name.lowercase()
var section = config.getConfigurationSection(otherName) var section = config.getConfigurationSection(otherName)
if (section == null) { if (section == null) {
section = config.getConfigurationSection(otherName.lowercase()) section = config.getConfigurationSection(otherName.uppercase())
if (section == null) return null if (section == null) return null
} }
@ -44,11 +44,11 @@ object UnitRepairUtil {
* If value is set to less than or equal to 0 then it will be set to default * If value is set to less than or equal to 0 then it will be set to default
*/ */
private fun getRepairAmount(item: ItemStack, section: ConfigurationSection, default: Double): Double? { private fun getRepairAmount(item: ItemStack, section: ConfigurationSection, default: Double): Double? {
val itemName = item.type.name.uppercase() val itemName = item.type.name.lowercase()
val repairValue = if (section.isDouble(itemName)) { val repairValue = if (section.isDouble(itemName)) {
section.getDouble(itemName) section.getDouble(itemName)
} else if (section.isDouble(itemName.lowercase())) { } else if (section.isDouble(itemName.uppercase())) {
section.getDouble(itemName.lowercase()) section.getDouble(itemName.uppercase())
} else { } else {
return null return null
} }