Reimplemented %active_level%

This commit is contained in:
Auxilor 2023-06-18 13:40:50 +02:00
parent 35564c6891
commit 762ff2524f
3 changed files with 21 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import com.willfp.ecoenchants.display.EnchantSorter
import com.willfp.ecoenchants.enchants.EcoEnchantLevel
import com.willfp.ecoenchants.enchants.EcoEnchants
import com.willfp.ecoenchants.enchants.EnchantGUI
import com.willfp.ecoenchants.enchants.FoundEcoEnchantLevel
import com.willfp.ecoenchants.enchants.LoreConversion
import com.willfp.ecoenchants.enchants.registerVanillaEnchants
import com.willfp.ecoenchants.integrations.EnchantRegistrations
@ -62,10 +63,10 @@ class EcoEnchantsPlugin : LibreforgePlugin() {
override fun handleEnable() {
registerHolderProvider { it.heldEnchantLevels }
registerPlayerRefreshFunction { it.clearEnchantCache() }
registerHolderPlaceholderProvider<EcoEnchantLevel> { it, player ->
registerHolderPlaceholderProvider<FoundEcoEnchantLevel> { it, _ ->
listOf(
NamedValue("level", it.level),
//NamedValue("active_level", player.getActiveEnchantLevel(it.enchant))
NamedValue("active_level", it.activeLevel)
)
}
}

View File

@ -31,3 +31,12 @@ class EcoEnchantLevel(
return Objects.hash(this.id)
}
}
data class FoundEcoEnchantLevel(
val level: EcoEnchantLevel,
val activeLevel: Int
): Holder {
override val effects = level.effects
override val conditions = level.conditions
override val id = level.id
}

View File

@ -5,6 +5,7 @@ import com.willfp.eco.core.fast.fast
import com.willfp.eco.core.items.HashedItem
import com.willfp.ecoenchants.enchants.EcoEnchant
import com.willfp.ecoenchants.enchants.EcoEnchantLevel
import com.willfp.ecoenchants.enchants.FoundEcoEnchantLevel
import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel
import com.willfp.libreforge.ItemProvidedHolder
import com.willfp.libreforge.ProvidedHolder
@ -304,7 +305,14 @@ object EnchantLookup {
}
}
return found
return found.map {
val level = it.holder as EcoEnchantLevel
ItemProvidedHolder(
FoundEcoEnchantLevel(level, this.getActiveEnchantLevel(level.enchant)),
it.provider
)
}
}
/**