diff --git a/build.gradle.kts b/build.gradle.kts index 28cfc3d..8c2f26d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "io.delilaheve" -version = "1.1.2" +version = "1.1.3" repositories { mavenCentral() diff --git a/src/main/resources/logo.png b/logo.png similarity index 100% rename from src/main/resources/logo.png rename to logo.png diff --git a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt index ccb37d8..96f4b44 100644 --- a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt +++ b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt @@ -66,7 +66,7 @@ class AnvilEventListener : Listener { resultItem.itemMeta?.let { if(!it.displayName.contentEquals(inventory.renameText)){ it.setDisplayName(inventory.renameText) - anvilCost += 1 + anvilCost += ConfigOptions.itemRepairCost } resultItem.itemMeta = it } @@ -135,8 +135,7 @@ class AnvilEventListener : Listener { )){ // There may an issue when illegal enchant are trying to combine // at least that what I think, but can't find why - illegalPenalty++ - UnsafeEnchants.log("Conflict for ${enchantment.key.enchantmentName}, add 1 of value") + illegalPenalty += ConfigOptions.sacrificeIllegalCost continue } diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index 1d402e5..9dbaa65 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -17,6 +17,10 @@ object ConfigOptions { private const val LIMIT_REPAIR_COST = "limit_repair_cost" // Path for repair value limit 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 illegal enchantment on sacrifice + private const val SACRIFICE_ILLEGAL_COST = "sacrifice_illegal_enchant_cost" // Path for removing repair cost limits private const val REMOVE_REPAIR_LIMIT = "remove_repair_limit" // Root path for enchantment limits @@ -30,15 +34,23 @@ object ConfigOptions { private const val DEBUG_LOGGING = "debug_log" // Default value for enchantment limits - private const val DEFAULT_ENCHANT_LIMIT = 10 + private const val DEFAULT_ENCHANT_LIMIT = 5 // Default value for allowing unsafe enchantments private const val DEFAULT_ALLOW_UNSAFE = true // Default value for limiting repair cost private const val DEFAULT_LIMIT_REPAIR = true // Default value for repair cost limit 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 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 + private val ITEM_REPAIR_COST_RANGE = 0..255 + // Valid range for repair cost limit + private val SACRIFICE_ILLEGAL_COST_RANGE = 0..255 // Default for removing repair cost limits private const val DEFAULT_REMOVE_LIMIT = false // Valid range for an enchantment limit @@ -90,6 +102,29 @@ object ConfigOptions { ?: DEFAULT_LIMIT_REPAIR_VALUE } + /** + * Value to limit repair costs to + */ + val itemRepairCost: Int + get() { + return UnsafeEnchants.instance + .config + .getInt(ITEM_REPAIR_COST, DEFAULT_ITEM_REPAIR_COST) + .takeIf { it in ITEM_REPAIR_COST_RANGE } + ?: DEFAULT_ITEM_REPAIR_COST + } + + /** + * Value to limit repair costs to + */ + val sacrificeIllegalCost: Int + get() { + return UnsafeEnchants.instance + .config + .getInt(SACRIFICE_ILLEGAL_COST, DEFAULT_SACRIFICE_ILLEGAL_COST) + .takeIf { it in SACRIFICE_ILLEGAL_COST_RANGE } + ?: DEFAULT_SACRIFICE_ILLEGAL_COST + } /** * Whether to remove repair cost limit */ diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index aa8e2e2..ad073a0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,6 +22,16 @@ limit_repair_cost: true # Valid range of 1 - 39 (vanilla will consider 40+ as "too expensive") limit_repair_value: 39 +# Value added to the anvil when the item durability increase +# +# Valid range of 0 - 255 +item_repair_cost: 2 + +# Value added to the anvil when the sacrifice try to add illegal enchant to the item +# +# Valid range of 0 - 255 +sacrifice_illegal_enchant_cost: 1 + # Whether the anvil's repair limit should be removed entirely # # The anvil will still visually display "too expensive" however the action will be completable diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1128c02..9e3b21c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ main: io.delilaheve.UnsafeEnchants name: UnsafeEnchantsPlus prefix: UnsafeEnchants+ -version: 1.1.2 +version: 1.1.3 description: Allow custom illegal enchantment api-version: 1.18 load: POSTWORLD