diff --git a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt index 4139067..bb24bbe 100644 --- a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt +++ b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt @@ -54,7 +54,7 @@ class AnvilEventListener : Listener { if (!first.isBook() && !second.isBook()) { // we only need to be concerned with repair when neither item is a book val repaired = resultItem.repairFrom(first, second) - anvilCost += if(repaired) 2 else 0 + anvilCost += if(repaired) ConfigOptions.itemRepairCost else 0 } // Test if nothing change and stop. @@ -67,7 +67,7 @@ class AnvilEventListener : Listener { resultItem.itemMeta?.let { if(!it.displayName.contentEquals(inventory.renameText)){ it.setDisplayName(inventory.renameText) - anvilCost += ConfigOptions.itemRepairCost + anvilCost += ConfigOptions.itemRenameCost } resultItem.itemMeta = it } diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index d548cb2..c142495 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -17,6 +17,8 @@ object ConfigOptions { private const val LIMIT_REPAIR_VALUE = "limit_repair_value" // Path for level cost on item repair private const val ITEM_REPAIR_COST = "item_repair_cost" + // Path for level cost on item renaming + private const val ITEM_RENAME_COST = "item_rename_cost" // Path for level cost on illegal enchantment on sacrifice private const val SACRIFICE_ILLEGAL_COST = "sacrifice_illegal_enchant_cost" // Path for removing repair cost limits @@ -39,13 +41,17 @@ object ConfigOptions { private const val DEFAULT_LIMIT_REPAIR_VALUE = 39 // Default value for level cost on item repair private const val DEFAULT_ITEM_REPAIR_COST = 2 + // Default value for level cost on item renaming + private const val DEFAULT_ITEM_RENAME_COST = 1 // Default value for level cost on illegal enchantment on sacrifice private const val DEFAULT_SACRIFICE_ILLEGAL_COST = 1 // Valid range for repair cost limit private val REPAIR_LIMIT_RANGE = 1..39 - // Valid range for repair cost limit + // Valid range for repair cost private val ITEM_REPAIR_COST_RANGE = 0..255 - // Valid range for repair cost limit + // Valid range for rename cost + private val ITEM_RENAME_COST_RANGE = 0..255 + // Valid range for illegal enchantment conflict cost private val SACRIFICE_ILLEGAL_COST_RANGE = 0..255 // Default for removing repair cost limits private const val DEFAULT_REMOVE_LIMIT = false @@ -89,7 +95,7 @@ object ConfigOptions { } /** - * Value to limit repair costs to + * Value of an item repair */ val itemRepairCost: Int get() { @@ -101,7 +107,19 @@ object ConfigOptions { } /** - * Value to limit repair costs to + * Value of an item rename + */ + val itemRenameCost: Int + get() { + return UnsafeEnchants.instance + .config + .getInt(ITEM_RENAME_COST, DEFAULT_ITEM_RENAME_COST) + .takeIf { it in ITEM_RENAME_COST_RANGE } + ?: DEFAULT_ITEM_RENAME_COST + } + + /** + * Value of illegal enchantment conflict */ val sacrificeIllegalCost: Int get() { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b434ad8..19a97ab 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -18,6 +18,11 @@ remove_repair_limit: false # Valid range of 0 - 255 item_repair_cost: 2 +# Value added to the anvil when the item is renamed +# +# Valid range of 0 - 255 +item_rename_cost: 1 + # Value added to the anvil when a sacrifice enchantment conflict # with one of the left item enchantment #