diff --git a/build.gradle.kts b/build.gradle.kts index 3e79591..7fa9457 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "xyz.alexcrea" -version = "1.4.2a" +version = "1.4.3a" repositories { mavenCentral() diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index 7d3b6d7..b69ad46 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -217,7 +217,7 @@ object ConfigOptions { * Get the given [enchantment]'s limit */ fun enchantLimit(enchantment: Enchantment): Int { - val path = "${ENCHANT_LIMIT_ROOT}.${enchantment.enchantmentName}" + val path = "${ENCHANT_LIMIT_ROOT}.${getEnchantKey(enchantment)}" return CustomAnvil.instance .config .getInt(path, defaultEnchantLimit) @@ -234,7 +234,7 @@ object ConfigOptions { isFromBook: Boolean ): Int { val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM - val path = "${ENCHANT_VALUES_ROOT}.${enchantment.enchantmentName}.$typeKey" + val path = "${ENCHANT_VALUES_ROOT}.${getEnchantKey(enchantment)}.$typeKey" return CustomAnvil.instance .config .getInt(path, DEFAULT_ENCHANT_VALUE) @@ -242,6 +242,13 @@ object ConfigOptions { ?: DEFAULT_ENCHANT_VALUE } + fun getEnchantKey(enchantment: Enchantment) : String{ + val enchantKey = enchantment.enchantmentName + if(enchantKey == "sweeping_edge"){ // compatibility with 1.20.5. TODO better update system + return "sweeping" + } + return enchantKey + } /** * Get an array of key of basic config options */ diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt index e4ce6f8..5f7aab1 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/group/EnchantConflictManager.kt @@ -24,6 +24,12 @@ class EnchantConflictManager { // Default name for a joining group private const val DEFAULT_GROUP_NAME = "joinedGroup" + + // 1.20.5 compatibility TODO better update system + private val SWEEPING_EDGE_ENCHANT = + Enchantment.getByKey(NamespacedKey.minecraft("sweeping_edge")) ?: + Enchantment.SWEEPING_EDGE + } private lateinit var conflictMap: HashMap> @@ -76,8 +82,7 @@ class EnchantConflictManager { // Read and add enchantment to conflict val enchantList = section.getStringList(ENCH_LIST_PATH) for (enchantName in enchantList) { - val enchantKey = NamespacedKey.minecraft(enchantName) - val enchant = Enchantment.getByKey(enchantKey) + val enchant = getEnchantByName(enchantName); if (enchant == null) { if (!futureUse) { CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName") @@ -95,6 +100,20 @@ class EnchantConflictManager { return conflict } + private fun getEnchantByName(enchantName: String): Enchantment? { + + // Teporary solution for 1.20.5 + when(enchantName){ + "sweeping", "sweeping_edge" -> { + return SWEEPING_EDGE_ENCHANT + } + } + + val enchantKey = NamespacedKey.minecraft(enchantName) + return Enchantment.getByKey(enchantKey); + } + + private fun createConflictObject( section: ConfigurationSection, itemManager: ItemGroupManager, diff --git a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt index 6e0e270..46f7cf5 100644 --- a/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt +++ b/src/main/kotlin/xyz/alexcrea/cuanvil/util/MetricsUtil.kt @@ -8,9 +8,9 @@ import xyz.alexcrea.cuanvil.config.ConfigHolder object MetricsUtil { private const val baseConfigHash = -1592940914 - private const val enchantLimitsConfigHash = -1014133828 - private const val enchantValuesConfigHash = 1072574774 - private const val enchantConflictConfigHash = 1406650190 + private const val enchantLimitsConfigHash = -275034280 + private const val enchantValuesConfigHash = -17048020 + private const val enchantConflictConfigHash = 546475833 private const val itemGroupsConfigHash = 1406650190 private const val unitRepairItemConfigHash = 536871958 private const val customAnvilCraftConfigHash = 0 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 61f169b..7e2435c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -72,6 +72,7 @@ enchant_limits: fire_aspect: 2 looting: 3 sweeping: 3 + sweeping_edge: 3 efficiency: 5 unbreaking: 3 fortune: 3 @@ -208,6 +209,9 @@ enchant_values: sweeping: item: 4 book: 2 + sweeping_edge: + item: 4 + book: 2 thorns: item: 8 book: 4 @@ -223,3 +227,5 @@ debug_log: false # Whether to show verbose debug logging debug_log_verbose: false + +configVersion: 1.4.3 diff --git a/src/main/resources/enchant_conflict.yml b/src/main/resources/enchant_conflict.yml index c3d8867..387fc90 100644 --- a/src/main/resources/enchant_conflict.yml +++ b/src/main/resources/enchant_conflict.yml @@ -147,8 +147,8 @@ restriction_soul_speed: enchantments: [ soul_speed ] notAffectedGroups: [ enchanted_book, boots ] -restriction_sweeping: - enchantments: [ sweeping ] +restriction_sweeping_edge: + enchantments: [ sweeping, sweeping_edge ] notAffectedGroups: [ enchanted_book, swords ] # Do not exist in 1.18, that mean useInFuture will be set to true diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f41a940..f7e12fa 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ main: io.delilaheve.CustomAnvil name: CustomAnvil prefix: "Custom Anvil" -version: 1.4.2a +version: 1.4.3a description: Allow to customise anvil mechanics api-version: 1.18 load: POSTWORLD