Added %active_level% and fixed rapid

This commit is contained in:
Auxilor 2023-05-25 20:16:22 +01:00
parent 9086c69f5b
commit dda1f11c14
4 changed files with 13 additions and 7 deletions

View File

@ -28,7 +28,9 @@ import com.willfp.ecoenchants.mechanics.GrindstoneSupport
import com.willfp.ecoenchants.mechanics.LootSupport
import com.willfp.ecoenchants.mechanics.VillagerSupport
import com.willfp.ecoenchants.target.EnchantLookup.clearEnchantCache
import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevel
import com.willfp.ecoenchants.target.EnchantLookup.heldEnchantLevels
import com.willfp.libreforge.EmptyProvidedHolder.holder
import com.willfp.libreforge.NamedValue
import com.willfp.libreforge.loader.LibreforgePlugin
import com.willfp.libreforge.loader.configs.ConfigCategory
@ -58,9 +60,12 @@ class EcoEnchantsPlugin : LibreforgePlugin() {
override fun handleEnable() {
registerHolderProvider { it.heldEnchantLevels }
registerPlayerRefreshFunction { it.clearEnchantCache() }
registerHolderPlaceholderProvider { (holder, _) ->
when (holder) {
is EcoEnchantLevel -> listOf(NamedValue("level", holder.level))
registerHolderPlaceholderProvider { ph, player ->
when (val holder = ph.holder) {
is EcoEnchantLevel -> listOf(
NamedValue("level", holder.level),
NamedValue("active_level", player.getActiveEnchantLevel(holder.enchant))
)
else -> emptyList()
}
}

View File

@ -7,13 +7,13 @@ import com.willfp.libreforge.effects.EffectList
import java.util.Objects
class EcoEnchantLevel(
parent: EcoEnchant,
val enchant: EcoEnchant,
val level: Int,
override val effects: EffectList,
override val conditions: ConditionList,
plugin: EcoPlugin
) : Holder {
override val id = plugin.createNamespacedKey("${parent.id}_$level")
override val id = plugin.createNamespacedKey("${enchant.id}_$level")
override fun equals(other: Any?): Boolean {
if (other !is EcoEnchantLevel) {

View File

@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchants.impl
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.enchants.EcoEnchant
import com.willfp.ecoenchants.target.EnchantLookup.getActiveEnchantLevel
import com.willfp.ecoenchants.target.EnchantLookup.getEnchantLevel
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
@ -31,7 +32,7 @@ class EnchantmentRapid(
fun handle(event: EntityShootBowEvent) {
val player = event.entity as? Player ?: return
val level = player.getEnchantLevel(enchant)
val level = player.getActiveEnchantLevel(enchant)
val multiplier = 1 - enchant.config.getDouble("percent-faster-per-level") * level / 100

View File

@ -1,5 +1,5 @@
#libreforge-updater
#Wed May 24 14:58:23 BST 2023
kotlin.code.style=official
libreforge-version=4.16.1
libreforge-version=4.17.0
version=10.16.1