From ac9f4921258b8a952be913b7066b71bb79c550e1 Mon Sep 17 00:00:00 2001 From: alexcrea Date: Mon, 25 May 2026 17:50:02 +0200 Subject: [PATCH] monetary minimum version & rename impl --- defaultconfigs/1.18/config.yml | 2 ++ defaultconfigs/1.21.11/config.yml | 2 ++ defaultconfigs/1.21.9/config.yml | 2 ++ defaultconfigs/1.21/config.yml | 2 ++ .../xyz/alexcrea/cuanvil/util/RenameAnvilUtil.kt | 12 ++++++++++++ .../kotlin/io/delilaheve/util/ConfigOptions.kt | 15 +++++++++++---- src/main/resources/config.yml | 3 +++ 7 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/util/RenameAnvilUtil.kt diff --git a/defaultconfigs/1.18/config.yml b/defaultconfigs/1.18/config.yml index 3edea26..1a1663a 100644 --- a/defaultconfigs/1.18/config.yml +++ b/defaultconfigs/1.18/config.yml @@ -432,6 +432,8 @@ lore_edit: # Allow to replace the xp cost by a monetary cost # If enabled it will not be bound to the experience level limits +# +# This feature can only be enabled starting with 1.21 monetary_cost: enabled: false # If using vault unlocked this allow to specify what currency should be used for anvil usage diff --git a/defaultconfigs/1.21.11/config.yml b/defaultconfigs/1.21.11/config.yml index 53ffabd..2daa373 100644 --- a/defaultconfigs/1.21.11/config.yml +++ b/defaultconfigs/1.21.11/config.yml @@ -452,6 +452,8 @@ lore_edit: # Allow to replace the xp cost by a monetary cost # If enabled it will not be bound to the experience level limits +# +# This feature can only be enabled starting with 1.21 monetary_cost: enabled: false # If using vault unlocked this allow to specify what currency should be used for anvil usage diff --git a/defaultconfigs/1.21.9/config.yml b/defaultconfigs/1.21.9/config.yml index 40e558d..8532881 100644 --- a/defaultconfigs/1.21.9/config.yml +++ b/defaultconfigs/1.21.9/config.yml @@ -444,6 +444,8 @@ lore_edit: # Allow to replace the xp cost by a monetary cost # If enabled it will not be bound to the experience level limits +# +# This feature can only be enabled starting with 1.21 monetary_cost: enabled: false # If using vault unlocked this allow to specify what currency should be used for anvil usage diff --git a/defaultconfigs/1.21/config.yml b/defaultconfigs/1.21/config.yml index 87372a5..25e47dc 100644 --- a/defaultconfigs/1.21/config.yml +++ b/defaultconfigs/1.21/config.yml @@ -432,6 +432,8 @@ lore_edit: # Allow to replace the xp cost by a monetary cost # If enabled it will not be bound to the experience level limits +# +# This feature can only be enabled starting with 1.21 monetary_cost: enabled: false # If using vault unlocked this allow to specify what currency should be used for anvil usage diff --git a/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/util/RenameAnvilUtil.kt b/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/util/RenameAnvilUtil.kt new file mode 100644 index 0000000..279016b --- /dev/null +++ b/nms/v1_21R1/src/main/kotlin/xyz/alexcrea/cuanvil/util/RenameAnvilUtil.kt @@ -0,0 +1,12 @@ +package xyz.alexcrea.cuanvil.util + +import org.bukkit.inventory.InventoryView + +// TODO yet another cleanup to do on legacy removal branch +object RenameAnvilUtil { + + fun rename(view: InventoryView, name: String) { + view.title = name + } + +} \ No newline at end of file diff --git a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt index 487bb87..ddaa348 100644 --- a/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt +++ b/src/main/kotlin/io/delilaheve/util/ConfigOptions.kt @@ -9,7 +9,10 @@ import xyz.alexcrea.cuanvil.config.WorkPenaltyType.WorkPenaltyPart import xyz.alexcrea.cuanvil.dependency.DependencyManager import xyz.alexcrea.cuanvil.dependency.economy.EconomyManager import xyz.alexcrea.cuanvil.enchant.CAEnchantment +import xyz.alexcrea.cuanvil.update.UpdateUtils +import xyz.alexcrea.cuanvil.update.Version import xyz.alexcrea.cuanvil.util.AnvilUseType +import java.math.BigDecimal import java.util.* /** @@ -87,6 +90,9 @@ object ConfigOptions { const val DEBUG_LOGGING = "debug_log" const val VERBOSE_DEBUG_LOGGING = "debug_log_verbose" + // Minimum versions + val MINIMUM_MONETARY_COST_VER = Version(21, 0, 0) + // ---------------------- // Default config values // ---------------------- @@ -637,11 +643,12 @@ object ConfigOptions { } /* - * Monetary configs + * Monetary configs (only for 1.21+) */ val shouldUseMoney: Boolean get() { return EconomyManager.economy?.initialized() == true && + UpdateUtils.currentMinecraftVersion().greaterEqual(MINIMUM_MONETARY_COST_VER) && ConfigHolder.DEFAULT_CONFIG .config .getBoolean(SHOULD_USE_MONEY, DEFAULT_SHOULD_USE_MONEY) @@ -654,10 +661,10 @@ object ConfigOptions { .getString(MONEY_CURRENCY, DEFAULT_MONEY_CURRENCY)!! } - fun getMonetaryMultiplier(type: String): Double { - return ConfigHolder.DEFAULT_CONFIG + fun getMonetaryMultiplier(type: String): BigDecimal { + return BigDecimal(ConfigHolder.DEFAULT_CONFIG .config - .getDouble("$MONETARY_MULTIPLIER_ROOT.$type", DEFAULT_MONEY_MULTIPLIER) + .getDouble("$MONETARY_MULTIPLIER_ROOT.$type", DEFAULT_MONEY_MULTIPLIER)) } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f5e2c5a..5ba61ec 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -434,6 +434,8 @@ lore_edit: # Allow to replace the xp cost by a monetary cost # If enabled it will not be bound to the experience level limits +# +# This feature can only be enabled starting with 1.21 monetary_cost: enabled: false # If using vault unlocked this allow to specify what currency should be used for anvil usage @@ -448,6 +450,7 @@ monetary_cost: repair: 1.0 # for repairing via unit repair (per unit) rename: 1.0 # for renaming the item lore_edit: 1.0 # for changing the lore of the item (only if lore edit is enabled) + illegal_penalty: 1.0 # for trying to combine illegal enchantment work_penalty: 1.0 # for work penalty (aka use penalty) recipe: 1.0 # for custom anvil recipe cost