Skip to content

Commit

Permalink
Fixed not met effects
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jul 23, 2023
1 parent 553363e commit 937bb89
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.willfp.libreforge.Compiled
import com.willfp.libreforge.EmptyProvidedHolder
import com.willfp.libreforge.ProvidedHolder
import com.willfp.libreforge.applyHolder
import com.willfp.libreforge.effects.Chain
import com.willfp.libreforge.effects.EffectList
import org.bukkit.Bukkit
import org.bukkit.entity.Player
Expand All @@ -19,7 +20,7 @@ class ConditionBlock<T> internal constructor(
val condition: Condition<T>,
override val config: Config,
override val compileData: T,
val notMetEffects: EffectList,
val notMetEffects: Chain?,
val notMetLines: List<String>,
val showNotMet: Boolean,
val isInverted: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ConditionList(
return true
}

notMet.forEach { it.notMetEffects.trigger(trigger) }
notMet.forEach { it.notMetEffects?.trigger(trigger) }
}
.let { false }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ import com.willfp.libreforge.integrations.paper.impl.ConditionInRain
import com.willfp.libreforge.integrations.paper.impl.ConditionInBubble
import com.willfp.libreforge.integrations.paper.impl.ConditionInLava
import com.willfp.libreforge.conditions.impl.ConditionOnGround
import com.willfp.libreforge.effects.Chain
import com.willfp.libreforge.effects.Effects
import com.willfp.libreforge.effects.executors.impl.NormalExecutorFactory
import com.willfp.libreforge.separatorAmbivalent

object Conditions : Registry<Condition<*>>() {
Expand Down Expand Up @@ -98,11 +100,18 @@ object Conditions : Registry<Condition<*>>() {
return null
}

return makeBlock(condition, config.getSubsection("args"), context.with("args"))
val notMetEffects = Effects.compileChain(
config.getSubsections("not-met-effects"),
NormalExecutorFactory.create(),
context.with("not-met-effects")
)

return makeBlock(condition, notMetEffects, config.getSubsection("args"), context.with("args"))
}

private fun <T> makeBlock(
condition: Condition<T>,
notMetEffects: Chain?,
config: Config,
context: ViolationContext
): ConditionBlock<T>? {
Expand All @@ -112,11 +121,6 @@ object Conditions : Registry<Condition<*>>() {

val compileData = condition.makeCompileData(config, context)

val notMetEffects = Effects.compile(
config.getSubsections("not-met-effects"),
context.with("not-met-effects")
)

return ConditionBlock(
condition,
config,
Expand Down

0 comments on commit 937bb89

Please sign in to comment.