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() { override fun handleEnable() {
registerHolderProvider { it.heldEnchantLevels } registerHolderProvider { it.heldEnchantLevels }
registerPlayerRefreshFunction { it.clearEnchantCache() } registerPlayerRefreshFunction { it.clearEnchantCache() }
registerHolderPlaceholderProvider<FoundEcoEnchantLevel> { it, _ -> registerHolderPlaceholderProvider<FoundEcoEnchantLevel> { it, _ ->
listOf( listOf(
NamedValue("level", it.level.level), NamedValue("level", it.level.level),
NamedValue("active_level", it.activeLevel) NamedValue("active_level", it.activeLevel)
) )
} }
registerHolderPlaceholderProvider<EcoEnchantLevel> { it, _ ->
listOf(
NamedValue("level", it.level),
)
}
} }
override fun handleAfterLoad() { override fun handleAfterLoad() {

View File

@ -308,7 +308,7 @@ object EnchantLookup {
// This is such a fucking disgusting way of implementing %active_level%, // This is such a fucking disgusting way of implementing %active_level%,
// and it's probably quite slow too. // 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 { found.map {
val level = it.holder as EcoEnchantLevel val level = it.holder as EcoEnchantLevel

View File

@ -167,6 +167,8 @@ lore-conversion:
enabled: false # If lore conversion should be enabled 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 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 # Extra placeholders for enchantment configs
internal-placeholders: extra-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 # 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