monetary minimum version & rename impl

This commit is contained in:
alexcrea 2026-05-25 17:50:02 +02:00
parent 1660250ee1
commit ac9f492125
Signed by: alexcrea
GPG key ID: E346CD16413450E3
7 changed files with 34 additions and 4 deletions

View file

@ -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))
}
}

View file

@ -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