One day I'll rewrite EnchantLookup.kt

This commit is contained in:
Auxilor 2023-07-17 16:56:42 +01:00
parent 5609c6eec2
commit 0d5f830192
3 changed files with 13 additions and 4 deletions

View File

@ -63,12 +63,19 @@ class EcoEnchantsPlugin : LibreforgePlugin() {
override fun handleEnable() {
registerHolderProvider { it.heldEnchantLevels }
registerPlayerRefreshFunction { it.clearEnchantCache() }
registerHolderPlaceholderProvider<FoundEcoEnchantLevel> { it, _ ->
listOf(
NamedValue("level", it.level.level),
NamedValue("active_level", it.activeLevel)
)
}
registerHolderPlaceholderProvider<EcoEnchantLevel> { it, _ ->
listOf(
NamedValue("level", it.level),
)
}
}
override fun handleAfterLoad() {

View File

@ -308,7 +308,7 @@ object EnchantLookup {
// This is such a fucking disgusting way of implementing %active_level%,
// and it's probably quite slow too.
return if (EcoEnchantsPlugin.instance.configYml.getBool("internal-placeholders.active-level")) {
return if (EcoEnchantsPlugin.instance.configYml.getBool("extra-placeholders.active-level")) {
found.map {
val level = it.holder as EcoEnchantLevel

View File

@ -167,6 +167,8 @@ lore-conversion:
enabled: false # If lore conversion should be enabled
aggressive: false # Will convert all items in all inventories when opened, likely to use a lot of performance
#Options for enable or disable placeholders of EcoEnchants
internal-placeholders:
active-level: true # Enable or disable %active_level% placeholder. Can be disabled to save some cpu time, if you don't use this placeholder
# Extra placeholders for enchantment configs
extra-placeholders:
# Enable or disable %active_level% placeholder.
# It's disabled by default to save CPU time, enable if you want to use it.
active-level: false