From e7662851f5fd49a0c116a04e48a08d3fc629ba7e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 13:27:39 +0000 Subject: [PATCH 01/11] Effects are now triggered by Dispatchers rather than Players --- .../libreforge/conditions/ConditionBlock.kt | 8 +++ .../libreforge/conditions/ConditionList.kt | 14 ++++- .../libreforge/counters/bind/BoundCounter.kt | 4 +- .../com/willfp/libreforge/effects/Chain.kt | 19 +++++- .../arguments/impl/ArgumentChainArgs.kt | 3 +- .../arguments/impl/ArgumentCooldown.kt | 50 ++++++++-------- .../effects/arguments/impl/ArgumentCost.kt | 13 ++-- .../effects/arguments/impl/ArgumentEvery.kt | 6 +- .../arguments/impl/ArgumentPointCost.kt | 12 ++-- .../effects/arguments/impl/ArgumentPrice.kt | 22 ++++--- .../libreforge/effects/impl/EffectAOE.kt | 3 +- .../effects/impl/EffectAOEBlocks.kt | 3 +- .../effects/impl/EffectAllPlayers.kt | 3 +- .../effects/impl/EffectRandomPlayer.kt | 3 +- .../libreforge/effects/impl/EffectRunChain.kt | 3 +- .../effects/impl/EffectRunChainInline.kt | 3 +- .../effects/impl/EffectTriggerNestedChain.kt | 3 +- .../aureliumskills/impl/ArgumentManaCost.kt | 10 +++- .../citizens/impl/TriggerLeftClickNPC.kt | 3 +- .../citizens/impl/TriggerRightClickNPC.kt | 3 +- .../jobs/impl/TriggerJobsLevelUp.kt | 3 +- .../paper/impl/EffectDropPickupItem.kt | 3 +- .../paper/impl/TriggerBeaconEffect.kt | 3 +- .../paper/impl/TriggerElytraBoost.kt | 3 +- .../integrations/paper/impl/TriggerSwing.kt | 3 +- .../paper/impl/TriggerVillagerTrade.kt | 3 +- .../scyther/impl/TriggerScytherAutoCollect.kt | 3 +- .../scyther/impl/TriggerScytherAutoSell.kt | 3 +- .../worldguard/impl/TriggerEnterRegion.kt | 3 +- .../worldguard/impl/TriggerLeaveRegion.kt | 3 +- .../com/willfp/libreforge/levels/LevelType.kt | 3 +- .../libreforge/triggers/DispatchedTrigger.kt | 21 ++++++- .../triggers/DispatchedTriggerFactory.kt | 19 ++++-- .../willfp/libreforge/triggers/Dispatcher.kt | 59 +++++++++++++++++++ .../com/willfp/libreforge/triggers/Trigger.kt | 47 ++++++++++++--- .../willfp/libreforge/triggers/TriggerData.kt | 15 ++++- .../triggers/event/TriggerDispatchEvent.kt | 15 ++++- .../triggers/impl/TriggerAltClick.kt | 3 +- .../libreforge/triggers/impl/TriggerBite.kt | 3 +- .../triggers/impl/TriggerBlockItemDrop.kt | 3 +- .../triggers/impl/TriggerBowAttack.kt | 3 +- .../libreforge/triggers/impl/TriggerBreed.kt | 3 +- .../libreforge/triggers/impl/TriggerBrew.kt | 3 +- .../triggers/impl/TriggerBrewIngredient.kt | 3 +- .../triggers/impl/TriggerCastRod.kt | 3 +- .../triggers/impl/TriggerCatchEntity.kt | 3 +- .../triggers/impl/TriggerCatchFish.kt | 3 +- .../triggers/impl/TriggerCatchFishFail.kt | 3 +- .../triggers/impl/TriggerChangeArmor.kt | 3 +- .../triggers/impl/TriggerChangeChunk.kt | 3 +- .../triggers/impl/TriggerChangeWorld.kt | 3 +- .../triggers/impl/TriggerClickBlock.kt | 3 +- .../triggers/impl/TriggerClickEntity.kt | 3 +- .../triggers/impl/TriggerConsume.kt | 3 +- .../libreforge/triggers/impl/TriggerCraft.kt | 3 +- .../triggers/impl/TriggerDamageItem.kt | 3 +- .../libreforge/triggers/impl/TriggerDeath.kt | 3 +- .../triggers/impl/TriggerDeployElytra.kt | 3 +- .../triggers/impl/TriggerDisable.kt | 3 +- .../libreforge/triggers/impl/TriggerDrink.kt | 3 +- .../triggers/impl/TriggerDropItem.kt | 3 +- .../triggers/impl/TriggerEmptyBucket.kt | 3 +- .../libreforge/triggers/impl/TriggerEnable.kt | 3 +- .../triggers/impl/TriggerEnchantItem.kt | 3 +- .../triggers/impl/TriggerEnterBed.kt | 3 +- .../triggers/impl/TriggerEntityItemDrop.kt | 3 +- .../triggers/impl/TriggerEntityTarget.kt | 3 +- .../triggers/impl/TriggerFallDamage.kt | 3 +- .../triggers/impl/TriggerFillBucket.kt | 3 +- .../triggers/impl/TriggerGainHunger.kt | 3 +- .../libreforge/triggers/impl/TriggerGainXp.kt | 3 +- .../triggers/impl/TriggerGroupCustom.kt | 3 +- .../triggers/impl/TriggerGroupStatic.kt | 3 +- .../triggers/impl/TriggerHeadshot.kt | 3 +- .../libreforge/triggers/impl/TriggerHeal.kt | 3 +- .../triggers/impl/TriggerHoldItem.kt | 3 +- .../triggers/impl/TriggerHookInGround.kt | 3 +- .../triggers/impl/TriggerItemBreak.kt | 3 +- .../libreforge/triggers/impl/TriggerJoin.kt | 3 +- .../libreforge/triggers/impl/TriggerJump.kt | 3 +- .../libreforge/triggers/impl/TriggerKill.kt | 5 +- .../triggers/impl/TriggerLeashEntity.kt | 3 +- .../libreforge/triggers/impl/TriggerLeave.kt | 3 +- .../triggers/impl/TriggerLeaveBed.kt | 3 +- .../triggers/impl/TriggerLevelUpItem.kt | 3 +- .../triggers/impl/TriggerLevelUpXp.kt | 3 +- .../triggers/impl/TriggerLoseHunger.kt | 3 +- .../triggers/impl/TriggerLosePotionEffect.kt | 3 +- .../triggers/impl/TriggerMeleeAttack.kt | 3 +- .../triggers/impl/TriggerMineBlock.kt | 3 +- .../triggers/impl/TriggerMineBlockProgress.kt | 3 +- .../libreforge/triggers/impl/TriggerMove.kt | 3 +- .../triggers/impl/TriggerPickUpItem.kt | 3 +- .../triggers/impl/TriggerPlaceBlock.kt | 3 +- .../triggers/impl/TriggerPotionEffect.kt | 3 +- .../triggers/impl/TriggerProjectileHit.kt | 5 +- .../triggers/impl/TriggerProjectileLaunch.kt | 3 +- .../libreforge/triggers/impl/TriggerReelIn.kt | 3 +- .../triggers/impl/TriggerRespawn.kt | 3 +- .../triggers/impl/TriggerRunCommand.kt | 3 +- .../triggers/impl/TriggerSellItem.kt | 3 +- .../triggers/impl/TriggerSendMessage.kt | 3 +- .../triggers/impl/TriggerShearEntity.kt | 3 +- .../triggers/impl/TriggerShieldBlock.kt | 3 +- .../triggers/impl/TriggerShootBow.kt | 3 +- .../libreforge/triggers/impl/TriggerSmelt.kt | 3 +- .../triggers/impl/TriggerSwapHands.kt | 3 +- .../triggers/impl/TriggerTakeDamage.kt | 3 +- .../triggers/impl/TriggerTakeEntityDamage.kt | 3 +- .../triggers/impl/TriggerTameAnimal.kt | 3 +- .../triggers/impl/TriggerTeleport.kt | 3 +- .../triggers/impl/TriggerToggleFlight.kt | 3 +- .../triggers/impl/TriggerToggleSneak.kt | 3 +- .../triggers/impl/TriggerToggleSprint.kt | 3 +- .../triggers/impl/TriggerTridentAttack.kt | 3 +- .../triggers/impl/TriggerWinRaid.kt | 3 +- 116 files changed, 470 insertions(+), 168 deletions(-) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt index 79ce15cc7..be40d0da3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt @@ -9,6 +9,8 @@ import com.willfp.libreforge.applyHolder import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.EffectList import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID @@ -35,6 +37,12 @@ class ConditionBlock internal constructor( .expireAfterAccess(10, TimeUnit.SECONDS) .build() + fun isMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean { + val player = dispatcher.get() ?: return false + + return isMet(player, holder) + } + fun isMet(player: Player, holder: ProvidedHolder): Boolean { /* diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt index 22d048dea..1a76841b7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt @@ -3,8 +3,12 @@ package com.willfp.libreforge.conditions import com.willfp.eco.util.formatEco import com.willfp.libreforge.DelegatedList import com.willfp.libreforge.EmptyProvidedHolder +import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.GlobalDispatcher.dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player /** @@ -19,11 +23,19 @@ class ConditionList( fun areMet(player: Player, holder: ProvidedHolder): Boolean = this.all { it.isMet(player, holder) } + /** + * Get if all conditions are met. + */ + fun areMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean { + val player = dispatcher.get() ?: return false + + return this.all { it.isMet(player, holder) } + } /** * Get if all conditions are met, triggering effects if not. */ fun areMetAndTrigger(trigger: DispatchedTrigger): Boolean = - filterNot { it.isMet(trigger.player, trigger.data.holder) } + filterNot { it.isMet(trigger.dispatcher, trigger.data.holder) } .also { notMet -> if (notMet.isEmpty()) { return true diff --git a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt index d99a842b4..9dbf55220 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt @@ -5,6 +5,8 @@ import com.willfp.eco.util.evaluateExpression import com.willfp.libreforge.counters.Accumulator import com.willfp.libreforge.counters.Counter import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Player /* @@ -21,7 +23,7 @@ internal data class BoundCounter( fun accept(trigger: DispatchedTrigger) { val data = trigger.data - val player = trigger.player + val player = trigger.dispatcher.get() ?: return val value = data.value if (!counter.canBeTriggeredBy(trigger.trigger)) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt index 9d8815d33..75a2cc2b7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt @@ -4,8 +4,11 @@ import com.willfp.libreforge.DelegatedList import com.willfp.libreforge.WeightedList import com.willfp.libreforge.effects.executors.ChainExecutor import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.triggers.impl.TriggerBlank import org.bukkit.entity.Player @@ -29,12 +32,26 @@ class Chain internal constructor( return executor.execute(this, trigger) } + fun trigger( + dispatcher: Dispatcher<*>, + data: TriggerData = TriggerData(player = dispatcher.get()), + trigger: Trigger = TriggerBlank, + executor: ChainExecutor = this.executor + ): Boolean { + return executor.execute(this, DispatchedTrigger(dispatcher, trigger, data)) + } + + @Deprecated( + "Use trigger(Dispatcher<*>, TriggerData, Trigger, ChainExecutor)", + ReplaceWith("trigger(dispatcher, data, trigger, executor)"), + DeprecationLevel.ERROR + ) fun trigger( player: Player, data: TriggerData = TriggerData(player = player), trigger: Trigger = TriggerBlank, executor: ChainExecutor = this.executor ): Boolean { - return executor.execute(this, DispatchedTrigger(player, trigger, data)) + return trigger(PlayerDispatcher(player), data, trigger, executor) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt index 7172266af..32fa243f7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.NamedValue import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get object ArgumentChainArgs : EffectArgument("chain_args") { // Misusing arguments a bit here but it's surprisingly clean @@ -19,7 +20,7 @@ object ArgumentChainArgs : EffectArgument("chain_args") { NamedValue( listOf(arg, arg.replace("_", "")), config.getFormattedString(arg, placeholderContext( - player = trigger.player, + player = trigger.dispatcher.get(), )) ) ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt index 004ee2770..056699cc2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt @@ -14,7 +14,9 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.ifType import org.bukkit.Sound +import org.bukkit.entity.Player import java.util.UUID import kotlin.math.ceil @@ -28,7 +30,7 @@ object ArgumentCooldown : EffectArgument("cooldown") { private fun getCooldown(element: ConfigurableElement, trigger: DispatchedTrigger): Int { val effectEndTimes = cooldownTracker[element.uuid] ?: return 0 - val endTime = effectEndTimes[trigger.player.uniqueId] ?: return 0 + val endTime = effectEndTimes[trigger.dispatcher.uuid] ?: return 0 val msLeft = endTime - System.currentTimeMillis() val secondsLeft = ceil(msLeft.toDouble() / 1000).toLong() @@ -37,7 +39,7 @@ object ArgumentCooldown : EffectArgument("cooldown") { override fun ifMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: Chain?) { val effectEndTimes = cooldownTracker[element.uuid] ?: mutableMapOf() - effectEndTimes[trigger.player.uniqueId] = System.currentTimeMillis() + + effectEndTimes[trigger.dispatcher.uuid] = System.currentTimeMillis() + (element.config.getDoubleFromExpression("cooldown", trigger.data) * 1000L).toLong() cooldownTracker[element.uuid] = effectEndTimes } @@ -57,28 +59,28 @@ object ArgumentCooldown : EffectArgument("cooldown") { return } - val player = trigger.player - - val message = element.config.getStringOrNull("cooldown_message") - ?.replace("%seconds%", cooldown.toString()) - ?.formatEco(trigger.player, true) - - ?: plugin.langYml.getFormattedString("messages.on-cooldown") - .replace("%seconds%", cooldown.toString()) - - if (plugin.configYml.getBool("cooldown.in-actionbar")) { - PlayerUtils.getAudience(player).sendActionBar(StringUtils.toComponent(message)) - } else { - player.sendMessage(message) - } - - if (plugin.configYml.getBool("cooldown.sound.enabled")) { - player.playSound( - player.location, - Sound.valueOf(plugin.configYml.getString("cooldown.sound.sound").uppercase()), - 1.0f, - plugin.configYml.getDouble("cooldown.sound.pitch").toFloat() - ) + trigger.dispatcher.ifType { player -> + val message = element.config.getStringOrNull("cooldown_message") + ?.replace("%seconds%", cooldown.toString()) + ?.formatEco(player, true) + + ?: plugin.langYml.getFormattedString("messages.on-cooldown") + .replace("%seconds%", cooldown.toString()) + + if (plugin.configYml.getBool("cooldown.in-actionbar")) { + PlayerUtils.getAudience(player).sendActionBar(StringUtils.toComponent(message)) + } else { + player.sendMessage(message) + } + + if (plugin.configYml.getBool("cooldown.sound.enabled")) { + player.playSound( + player.location, + Sound.valueOf(plugin.configYml.getString("cooldown.sound.sound").uppercase()), + 1.0f, + plugin.configYml.getDouble("cooldown.sound.pitch").toFloat() + ) + } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt index 77a5d0889..ad3a5d3eb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt @@ -10,21 +10,24 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get import org.bukkit.Sound +import org.bukkit.entity.Player object ArgumentCost : EffectArgument("cost") { override fun isMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData): Boolean { - val player = trigger.player + val player = trigger.dispatcher.get() ?: return false + return player.balance >= element.config.getDoubleFromExpression("cost", trigger.data) } override fun ifNotMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + if (!plugin.configYml.getBool("cannot-afford.message-enabled")) { return } - val player = trigger.player - val cost = element.config.getDoubleFromExpression("cost", trigger.data) val message = plugin.langYml.getFormattedString("messages.cannot-afford") @@ -47,6 +50,8 @@ object ArgumentCost : EffectArgument("cost") { } override fun ifMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { - trigger.player.balance -= element.config.getDoubleFromExpression("cost", trigger.data) + val player = trigger.dispatcher.get() ?: return + + player.balance -= element.config.getDoubleFromExpression("cost", trigger.data) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt index 48f892cfb..056fe4e15 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt @@ -12,7 +12,7 @@ object ArgumentEvery: EffectArgument("every") { private val everyHandler = nestedMap() override fun isMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData): Boolean { - val current = everyHandler[element.uuid][trigger.player.uniqueId] ?: 1 + val current = everyHandler[element.uuid][trigger.dispatcher.uuid] ?: 1 return current == 0 } @@ -28,7 +28,7 @@ object ArgumentEvery: EffectArgument("every") { private fun increment(element: ConfigurableElement, trigger: DispatchedTrigger) { val every = element.config.getIntFromExpression("every", trigger.data) - var current = everyHandler[element.uuid][trigger.player.uniqueId] ?: 1 + var current = everyHandler[element.uuid][trigger.dispatcher.uuid] ?: 1 current++ @@ -36,6 +36,6 @@ object ArgumentEvery: EffectArgument("every") { current = 0 } - everyHandler[element.uuid][trigger.player.uniqueId] = current + everyHandler[element.uuid][trigger.dispatcher.uuid] = current } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt index 7ed803efc..7b6bbac90 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt @@ -11,11 +11,13 @@ import com.willfp.libreforge.plugin import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get import org.bukkit.Sound +import org.bukkit.entity.Player object ArgumentPointCost : EffectArgument("point_cost") { override fun isMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData): Boolean { - val player = trigger.player + val player = trigger.dispatcher.get() ?: return false val cost = element.config.getDoubleFromExpression("point_cost.cost", trigger.data) val type = element.config.getString("point_cost.type") @@ -24,12 +26,12 @@ object ArgumentPointCost : EffectArgument("point_cost") { } override fun ifNotMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + if (!plugin.configYml.getBool("cannot-afford-type.message-enabled")) { return } - val player = trigger.player - val cost = element.config.getDoubleFromExpression("point_cost.cost", trigger.data) val type = element.config.getString("point_cost.type") @@ -54,9 +56,11 @@ object ArgumentPointCost : EffectArgument("point_cost") { } override fun ifMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + val cost = element.config.getDoubleFromExpression("point_cost.cost", trigger.data) val type = element.config.getString("point_cost.type") - trigger.player.points[type] -= cost + player.points[type] -= cost } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt index 0998f4086..1d3c9049b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt @@ -10,7 +10,9 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.plugin import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get import org.bukkit.Sound +import org.bukkit.entity.Player object ArgumentPrice : EffectArgument("price") { @@ -23,26 +25,32 @@ object ArgumentPrice : EffectArgument("price") { */ override fun isMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData): Boolean { + val player = trigger.dispatcher.get() ?: return false + val price = Prices.create( element.config.getString("price.value"), element.config.getString("price.type"), element.config.toPlaceholderContext(trigger.data) ) - return price.canAfford(trigger.player) + return price.canAfford(player) } override fun ifMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + val price = Prices.create( element.config.getString("price.value"), element.config.getString("price.type"), element.config.toPlaceholderContext(trigger.data) ) - price.pay(trigger.player) + price.pay(player) } override fun ifNotMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + if (!plugin.configYml.getBool("cannot-afford-price.message-enabled")) { return } @@ -54,20 +62,20 @@ object ArgumentPrice : EffectArgument("price") { ) val display = element.config.getString("price.display") - .replace("%value%", NumberUtils.format(price.getValue(trigger.player))) + .replace("%value%", NumberUtils.format(price.getValue(player))) val message = plugin.langYml.getFormattedString("messages.cannot-afford-price") .replace("%price%", display) if (plugin.configYml.getBool("cannot-afford-price.in-actionbar")) { - PlayerUtils.getAudience(trigger.player).sendActionBar(StringUtils.toComponent(message)) + PlayerUtils.getAudience(player).sendActionBar(StringUtils.toComponent(message)) } else { - trigger.player.sendMessage(message) + player.sendMessage(message) } if (plugin.configYml.getBool("cannot-afford-price.sound.enabled")) { - trigger.player.playSound( - trigger.player.location, + player.playSound( + player.location, Sound.valueOf(plugin.configYml.getString("cannot-afford-price.sound.sound").uppercase()), 1.0f, plugin.configYml.getDouble("cannot-afford-price.sound.pitch").toFloat() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt index 4cb43ba81..df8dc3f09 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt @@ -11,6 +11,7 @@ import com.willfp.libreforge.effects.impl.aoe.AOEBlock import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -42,7 +43,7 @@ object EffectAOE : Effect("aoe") { data.copy( victim = entity, location = entity.location - ).dispatch(player) + ).dispatch(PlayerDispatcher(player)) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt index f585ef1ff..3d178adc9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +41,7 @@ object EffectAOEBlocks : Effect("aoe_blocks") { data.copy( block = block, location = block.location.add(0.5, 0.5, 0.5) - ).dispatch(player) + ).dispatch(PlayerDispatcher(player)) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt index 496b4beb1..86a12e512 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt @@ -7,6 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -20,7 +21,7 @@ object EffectAllPlayers : Effect("all_players") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { for (player in Bukkit.getOnlinePlayers()) { compileData?.trigger( - data.dispatch(player), + data.dispatch(PlayerDispatcher(player)), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt index f5b2da48f..6f8593045 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt @@ -7,6 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -20,7 +21,7 @@ object EffectRandomPlayer : Effect("random_player") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { Bukkit.getOnlinePlayers().randomOrNull()?.let { player -> compileData?.trigger( - data.dispatch(player), + data.dispatch(PlayerDispatcher(player)), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt index 7f3519ebc..17cd8e5a2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt @@ -9,6 +9,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object EffectRunChain : Effect("run_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(player) + val dispatch = data.dispatch(PlayerDispatcher(player)) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt index 17039edfc..5b2a57ea0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt @@ -10,6 +10,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object EffectRunChainInline : Effect("run_chain_inline") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(player) + val dispatch = data.dispatch(PlayerDispatcher(player)) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt index 09466058a..cb722e132 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.RichChain import com.willfp.libreforge.effects.executors.ChainExecutors +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object EffectTriggerNestedChain : Effect("trigger_nested_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: RichChain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(player) + val dispatch = data.dispatch(PlayerDispatcher(player)) return compileData?.trigger(dispatch) == true } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt index 4df6ee0ca..f8e8abc3f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt @@ -11,11 +11,13 @@ import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.get import org.bukkit.Sound +import org.bukkit.entity.Player object ArgumentManaCost : EffectArgument("mana_cost") { override fun isMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData): Boolean { - val player = trigger.data.player + val player = trigger.dispatcher.get() ?: return false val cost = element.config.getDoubleFromExpression("mana_cost", trigger.data) @@ -23,13 +25,15 @@ object ArgumentManaCost : EffectArgument("mana_cost") { } override fun ifMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { + val player = trigger.dispatcher.get() ?: return + val cost = element.config.getDoubleFromExpression("mana_cost", trigger.data) - AureliumAPI.setMana(trigger.player, AureliumAPI.getMana(trigger.player) - cost) + AureliumAPI.setMana(player, AureliumAPI.getMana(player) - cost) } override fun ifNotMet(element: ConfigurableElement, trigger: DispatchedTrigger, compileData: NoCompileData) { - val player = trigger.player + val player = trigger.dispatcher.get() ?: return val cost = element.config.getDoubleFromExpression("mana_cost", trigger.data) diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt index ca1e977e6..b183d75bc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerLeftClickNPC : Trigger("left_click_npc") { val player = event.clicker ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt index 0a27aa998..3b8d5626f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerRightClickNPC : Trigger("right_click_npc") { val player = event.clicker ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt index d8af0c9e8..7e196f11b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsLevelUpEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerJobsLevelUp : Trigger("jobs_level_up") { val player = event.player.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt index cef5ee6d9..e4fc21407 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt @@ -13,6 +13,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.ChatColor @@ -48,7 +49,7 @@ object EffectDropPickupItem : Effect("drop_pickup_item") { val meta = Meta( chain, - data.dispatch(player), + data.dispatch(PlayerDispatcher(player)), glowColor?.let { TeamUtils.fromChatColor(it) } ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt index a542a84ca..ac258a323 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.block.BeaconEffectEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerBeaconEffect : Trigger("beacon_effect") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt index 116bb60af..4fd31ace6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerElytraBoost : Trigger("elytra_boost") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt index c1edf45b2..ee6384b0d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerSwing : Trigger("swing") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt index 611b534e5..b9c90fb45 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerVillagerTrade : Trigger("villager_trade") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = event.villager, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt index 9a7099431..5ea0d5c5f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerScytherAutoCollect : Trigger("scyther_auto_collect") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutocollectEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt index 19040a635..692689ade 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerScytherAutoSell : Trigger("scyther_auto_sell") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutosellEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt index 2bae1165b..fd9ee8024 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.integrations.worldguard.impl import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.Prerequisite +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -54,7 +55,7 @@ object TriggerEnterRegion : Trigger("enter_region") { for (region in entered) { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt index 835c99635..1ce04cf22 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.integrations.worldguard.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -14,7 +15,7 @@ object TriggerLeaveRegion : Trigger("leave_region") { fun dispatch(player: Player, event: RegionEvent) { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt index 8d424e09b..ae03d4365 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt @@ -14,6 +14,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.levels.event.ItemLevelUpEvent import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.impl.TriggerLevelUpItem import org.bukkit.Bukkit @@ -63,7 +64,7 @@ class LevelType( levelUpEffects?.trigger( DispatchedTrigger( - player, + PlayerDispatcher(player), TriggerLevelUpItem, TriggerData( player = player, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt index fa5346a03..6890c7e0b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt @@ -6,7 +6,7 @@ import com.willfp.libreforge.triggers.placeholders.TriggerPlaceholders import org.bukkit.entity.Player data class DispatchedTrigger( - val player: Player, + val dispatcher: Dispatcher<*>, val trigger: Trigger, val data: TriggerData ) { @@ -15,6 +15,25 @@ data class DispatchedTrigger( val placeholders: List get() = _placeholders.flatMap { it.placeholders } + @Deprecated( + "Use dispatcher instead", + ReplaceWith("dispatcher.get()"), + DeprecationLevel.ERROR + ) + val player: Player? + get() = dispatcher.get() + + @Deprecated( + "DispatchedTrigger should be constructed with a Dispatcher", + ReplaceWith("DispatchedTrigger(dispatcher, trigger, data)"), + DeprecationLevel.ERROR + ) + constructor( + player: Player, + trigger: Trigger, + data: TriggerData, + ) : this(PlayerDispatcher(player), trigger, data) + fun addPlaceholder(placeholder: NamedValue) { _placeholders += placeholder } diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt index 36e6acac8..ef71f538b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt @@ -14,25 +14,34 @@ Prevents multiple identical triggers from being triggered in the same tick. class DispatchedTriggerFactory( private val plugin: EcoPlugin ) { - private val playerTriggers = listMap() + private val dispatcherTriggers = listMap() + @Deprecated( + "Use create(dispatcher, trigger, data) instead", + ReplaceWith("create(dispatcher, trigger, data)"), + DeprecationLevel.ERROR + ) fun create(player: Player, trigger: Trigger, data: TriggerData): DispatchedTrigger? { + return create(PlayerDispatcher(player), trigger, data) + } + + fun create(dispatcher: Dispatcher<*>, trigger: Trigger, data: TriggerData): DispatchedTrigger? { if (!trigger.isEnabled) { return null } val hash = (trigger.hashCode() shl 5) xor data.hashCode() - if (hash in playerTriggers[player.uniqueId]) { + if (hash in dispatcherTriggers[dispatcher.uuid]) { return null } - playerTriggers[player.uniqueId] += hash - return DispatchedTrigger(player, trigger, data) + dispatcherTriggers[dispatcher.uuid] += hash + return DispatchedTrigger(dispatcher, trigger, data) } internal fun startTicking() { plugin.scheduler.runTimer(1, 1) { - playerTriggers.clear() + dispatcherTriggers.clear() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt new file mode 100644 index 000000000..82a21c806 --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt @@ -0,0 +1,59 @@ +package com.willfp.libreforge.triggers + +import org.bukkit.entity.Player +import java.util.UUID + +/** + * A dispatcher represents the object that dispatched a trigger (e.g. a player). + */ +interface Dispatcher { + /** + * The UUID of the dispatcher. + */ + val uuid: UUID + + /** + * The dispatcher itself. + */ + val dispatcher: T +} + +/** + * Get the dispatcher as a specific type. + */ +inline fun Dispatcher<*>.get(): T? { + return this.dispatcher as? T +} + +/** + * Check if the dispatcher is a specific type. + */ +inline fun Dispatcher<*>.isType(): Boolean { + return this.dispatcher is T +} + +/** + * Run a block if the dispatcher is a specific type. + */ +inline fun Dispatcher<*>.ifType(block: (T) -> Unit) { + val dispatcher = this.dispatcher as? T ?: return + block(dispatcher) +} + +/** + * A dispatcher for a player. + */ +class PlayerDispatcher( + override val dispatcher: Player +) : Dispatcher { + override val uuid + get() = dispatcher.uniqueId +} + +/** + * A dispatcher for the global scope. + */ +object GlobalDispatcher : Dispatcher { + override val uuid = UUID(0, 0) + override val dispatcher = Unit +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt index 25aa3c635..2e704ae76 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt @@ -1,6 +1,8 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.registry.KRegistrable +import com.willfp.libreforge.ProvidedEffectBlock +import com.willfp.libreforge.ProvidedEffectBlocks import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.counters.bind.BoundCounters import com.willfp.libreforge.counters.bind.BoundCounters.bindings @@ -34,17 +36,43 @@ abstract class Trigger( isEnabled = true } + @Deprecated( + "Use dispatch(dispatcher, data, forceHolders) instead", + ReplaceWith("dispatch(dispatcher, data, forceHolders)"), + DeprecationLevel.ERROR + ) + fun dispatch( + player: Player, + data: TriggerData, + forceHolders: Collection? = null + ) = dispatch(PlayerDispatcher(player), data, forceHolders) + /** * Dispatch the trigger. */ - protected fun dispatch( - player: Player, + fun dispatch( + dispatcher: Dispatcher<*>, data: TriggerData, forceHolders: Collection? = null ) { - val dispatch = plugin.dispatchedTriggerFactory.create(player, this, data) ?: return + if (dispatcher.isType()) { + val player = dispatcher.get()!! + val effects = forceHolders?.getProvidedActiveEffects(player) ?: player.providedActiveEffects + dispatchOnEffects(dispatcher, data, effects) + } else { + dispatchOnEffects(dispatcher, data, emptyList()) + } + } - val effects = forceHolders?.getProvidedActiveEffects(player) ?: player.providedActiveEffects + /** + * Dispatch the trigger on a collection of [ProvidedEffectBlock]s. + */ + fun dispatchOnEffects( + dispatcher: Dispatcher<*>, + data: TriggerData, + effects: Collection + ) { + val dispatch = plugin.dispatchedTriggerFactory.create(dispatcher, this, data) ?: return // Prevent dispatching useless triggers val potentialDestinations = effects.flatMap { it.effects } + BoundCounters.values() @@ -54,7 +82,7 @@ abstract class Trigger( dispatch.generatePlaceholders(data) - val dispatchEvent = TriggerDispatchEvent(player, dispatch) + val dispatchEvent = TriggerDispatchEvent(dispatcher, dispatch) Bukkit.getPluginManager().callEvent(dispatchEvent) if (dispatchEvent.isCancelled) { @@ -68,10 +96,12 @@ abstract class Trigger( } val withHolder = data.copy(holder = holder) - val dispatchWithHolder = DispatchedTrigger(player, this, withHolder).inheritPlaceholders(dispatch) + val dispatchWithHolder = DispatchedTrigger(dispatcher, this, withHolder).inheritPlaceholders(dispatch) - for (placeholder in holder.generatePlaceholders(player)) { - dispatchWithHolder.addPlaceholder(placeholder) + dispatcher.ifType { player -> + for (placeholder in holder.generatePlaceholders(player)) { + dispatchWithHolder.addPlaceholder(placeholder) + } } for (block in blocks) { @@ -85,6 +115,7 @@ abstract class Trigger( } } + final override fun onRegister() { plugin.runWhenEnabled { plugin.eventManager.unregisterListener(this) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt index 8c80758b5..c6c064d8e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt @@ -49,8 +49,19 @@ data class TriggerData( /** * Turn into a dispatched trigger for a [player]. */ - fun dispatch(player: Player) = DispatchedTrigger( - player, + @Deprecated( + "Use dispatch(dispatcher) instead", + ReplaceWith("dispatch(dispatcher)"), + DeprecationLevel.ERROR + ) + fun dispatch(player: Player) = + dispatch(PlayerDispatcher(player)) + + /** + * Turn into a dispatched trigger for a [dispatcher]. + */ + fun dispatch(dispatcher: Dispatcher<*>) = DispatchedTrigger( + dispatcher, TriggerBlank, this ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt index 329ff4dae..edd63db53 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt @@ -1,17 +1,28 @@ package com.willfp.libreforge.triggers.event import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.event.Cancellable +import org.bukkit.event.Event import org.bukkit.event.HandlerList import org.bukkit.event.player.PlayerEvent class TriggerDispatchEvent( - who: Player, + val dispatcher: Dispatcher<*>, val trigger: DispatchedTrigger -) : PlayerEvent(who), Cancellable { +) : Event(), Cancellable { private var _cancelled = false + @Deprecated( + "Use dispatcher instead", + ReplaceWith("dispatcher.get()"), + DeprecationLevel.ERROR + ) + val player: Player? + get() = dispatcher.get() + override fun isCancelled() = _cancelled override fun setCancelled(cancelled: Boolean) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt index 03d2c6e58..4bac71b9d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -130,7 +131,7 @@ object TriggerAltClick : Trigger("alt_click") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt index f99201800..6e6a6dfc7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerBite : Trigger("bite") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt index 4e51cba15..77a7afaec 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.libreforge.filterNotEmpty +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -48,7 +49,7 @@ object TriggerBlockItemDrop : Trigger("block_item_drop") { val editableEvent = EditableBlockDropEvent(event) this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, block = BrokenBlock(block, event.blockState.type), // Fixes the type always being AIR diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt index 1a714e8df..21ca0acac 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -45,7 +46,7 @@ object TriggerBowAttack : Trigger("bow_attack") { } this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt index 4a3d2850d..e076bf822 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerBreed : Trigger("breed") { val player = event.breeder as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt index e54f868b9..aa9b05065 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -52,7 +53,7 @@ object TriggerBrew : Trigger("brew") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt index eb7bfca3d..1a5954698 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -48,7 +49,7 @@ object TriggerBrewIngredient : Trigger("brew_ingredient") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = event.contents.ingredient, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt index 63e30801f..4f999a4a0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerCastRod : Trigger("cast_rod") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt index 8e8619a8f..c20974dc9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerCatchEntity : Trigger("catch_entity") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.caught?.location ?: player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt index 5bf8acfe9..bbd766a36 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerCatchFish : Trigger("catch_fish") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt index cceaac96c..aeaed2e64 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerCatchFishFail : Trigger("catch_fish_fail") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt index 5253fb9d3..f3aec7b28 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.ArmorChangeEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerChangeArmor : Trigger("change_armor") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt index d033e7e94..53656e366 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerChangeChunk : Trigger("change_chunk") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt index 44c919bf4..37f9dec44 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +23,7 @@ object TriggerChangeWorld : Trigger("change_world") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt index c93417c34..7f461cef4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +41,7 @@ object TriggerClickBlock : Trigger("click_block") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = block.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt index 15aa63927..c7ecccecd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +22,7 @@ object TriggerClickEntity : Trigger("click_entity") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt index 472dfe179..003eac7f4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerConsume : Trigger("consume") { fun handle(event: PlayerItemConsumeEvent) { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt index 9cc726b3e..fa80a1e3b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -91,7 +92,7 @@ object TriggerCraft : Trigger("craft") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt index b3abccea0..6714bf263 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +21,7 @@ object TriggerDamageItem : Trigger("damage_item") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt index 844e89ab4..1342eaccf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerDeath : Trigger("death") { val player = event.entity this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt index b54facfa5..5463d58e2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerDeployElytra : Trigger("deploy_elytra") { val player = event.entity as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt index f9e52c587..033329fe7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderDisableEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerDisable : Trigger("disable") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt index 52ed68e50..89daa18a4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -31,7 +32,7 @@ object TriggerDrink : Trigger("drink") { } val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt index 76ece7a20..52faafb22 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerDropItem : Trigger("drop_item") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = event.itemDrop.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt index 649eb3149..37454f65c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerEmptyBucket : Trigger("empty_bucket") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt index 31ff6dfa6..513f2f1ad 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderEnableEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerEnable : Trigger("enable") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt index 7e180f52f..b5d7aacf4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerEnchantItem : Trigger("enchant_item") { val item = event.item this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt index 19a2813e1..fb7d404f2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerEnterBed : Trigger("enter_bed") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt index a95c7c30f..59b97a45c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt @@ -5,6 +5,7 @@ import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer import com.willfp.libreforge.filterNotEmpty +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -35,7 +36,7 @@ object TriggerEntityItemDrop : Trigger("entity_item_drop") { val editableEvent = EditableEntityDropEvent(event.deathEvent) this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt index 82f17656b..0a370b444 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +21,7 @@ object TriggerEntityTarget : Trigger("entity_target") { val entity = event.entity as? LivingEntity ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt index a971fd204..afde7e607 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +28,7 @@ object TriggerFallDamage : Trigger("fall_damage") { } this.dispatch( - victim, + PlayerDispatcher(victim), TriggerData( player = victim, location = victim.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt index 860ff5365..09bd071af 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerFillBucket : Trigger("fill_bucket") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt index bd49dd0f8..d86c426b0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerGainHunger : Trigger("gain_hunger") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt index 85029eb9a..2fdb7f242 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.NaturalExpGainEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerGainXp : Trigger("gain_xp") { val player = event.expChangeEvent.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event.expChangeEvent, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt index 62229a5f7..c574599d8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -25,7 +26,7 @@ object TriggerGroupCustom : TriggerGroup("custom") { fun dispatch(player: Player, data: TriggerData) { super.dispatch( - player, + PlayerDispatcher(player), data, null ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt index 463355d40..a4e2cbf7a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -51,7 +52,7 @@ object TriggerGroupStatic : TriggerGroup("static") { } else null this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt index daeef0965..325cea9da 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -30,7 +31,7 @@ object TriggerHeadshot : Trigger("headshot") { } this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt index 6a55e2b28..3fafe7fb1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +23,7 @@ object TriggerHeal : Trigger("heal") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt index 8260aa0b2..892750241 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +23,7 @@ object TriggerHoldItem : Trigger("hold_item") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt index 5f37b8294..33c13da48 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerHookInGround : Trigger("hook_in_ground") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt index 824994561..de3a449bb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerItemBreak : Trigger("item_break") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt index 5b8cbcde8..80cf888e3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +16,7 @@ object TriggerJoin : Trigger("join") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerJoinEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt index a074b2c7d..480898c13 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.PlayerJumpEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerJump : Trigger("jump") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt index 082762373..92729b733 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +26,7 @@ object TriggerKill : Trigger("kill") { val victim = event.victim this.dispatch( - killer, + PlayerDispatcher(killer), TriggerData( player = killer, victim = victim, @@ -37,7 +38,7 @@ object TriggerKill : Trigger("kill") { fun force(player: Player, victim: LivingEntity) { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt index bf54d1037..0069683d4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +21,7 @@ object TriggerLeashEntity : Trigger("leash_entity") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt index 57573f362..98380314c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +16,7 @@ object TriggerLeave : Trigger("leave") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerQuitEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt index 3a362a7a9..b3aa9baab 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +18,7 @@ object TriggerLeaveBed : Trigger("leave_bed") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt index 690ceba00..c798d1535 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.levels.event.ItemLevelUpEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +16,7 @@ object TriggerLevelUpItem : Trigger("level_up_item") { @EventHandler fun handle(event: ItemLevelUpEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, item = event.item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt index 9a3be5714..957283314 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +22,7 @@ object TriggerLevelUpXp : Trigger("level_up_xp") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, value = event.newLevel.toDouble() diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt index b9075daa2..06b286f4c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerLoseHunger : Trigger("lose_hunger") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt index 1150d870e..9418a6d0b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +28,7 @@ object TriggerLosePotionEffect : Trigger("lose_potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt index 99cf2b1de..6cb34999a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -28,7 +29,7 @@ object TriggerMeleeAttack : Trigger("melee_attack") { } this.dispatch( - attacker, + PlayerDispatcher(attacker), TriggerData( player = attacker, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt index 5cbcbc4a7..9cb7c7708 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerMineBlock : Trigger("mine_block") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt index c89f4b225..c200318b9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +22,7 @@ object TriggerMineBlockProgress : Trigger("mine_block_progress") { val block = event.block this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index 62a22d769..60471945a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -33,7 +34,7 @@ object TriggerMove : Trigger("move") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt index 14540b0dc..7cb74e66a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerPickUpItem : Trigger("pick_up_item") { val player = event.entity as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = event.item.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt index 52f85fe8c..f2a130e20 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +27,7 @@ object TriggerPlaceBlock : Trigger("place_block") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt index 1a2c551ca..6c27c05dc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +24,7 @@ object TriggerPotionEffect : Trigger("potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt index b9c4ad5c5..acbcc7b47 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -31,7 +32,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { } this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, projectile = projectile, @@ -50,7 +51,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { val player = arrow.shooter as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt index 5a8442a3a..f40192797 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +26,7 @@ object TriggerProjectileLaunch : Trigger("projectile_launch") { } this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, projectile = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt index 22247001a..55c4d4422 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerReelIn : Trigger("reel_in") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt index 05d8858db..71aeb178c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +16,7 @@ object TriggerRespawn : Trigger("respawn") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerRespawnEvent) { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt index a43467b22..88bf748b2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +21,7 @@ object TriggerRunCommand : Trigger("run_command") { plugin.scheduler.run { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt index 4f5f3a00c..d6a25281a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerSellItem : Trigger("sell_item") { val item = event.item this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt index c20e2942c..5f12b4041 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +26,7 @@ object TriggerSendMessage : Trigger("send_message") { plugin.scheduler.run { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt index d989f9f81..3a7fd26fd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +25,7 @@ object TriggerShearEntity : Trigger("shear_entity") { } this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt index 36fcc68b7..51372ce68 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -35,7 +36,7 @@ object TriggerShieldBlock : Trigger("shield_block") { } this.dispatch( - victim, + PlayerDispatcher(victim), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt index 9bbafa6db..63abc664b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +26,7 @@ object TriggerShootBow : Trigger("shoot_bow") { } this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, projectile = event.projectile as? Projectile, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt index 59ff95dc7..d394ad0de 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +23,7 @@ object TriggerSmelt : Trigger("smelt") { val item = event.result this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt index a95d667ae..47b93a004 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +23,7 @@ object TriggerSwapHands : Trigger("swap_hands") { } this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt index c4273c968..6aa35d6a6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -38,7 +39,7 @@ object TriggerTakeDamage : Trigger("take_damage") { } this.dispatch( - victim, + PlayerDispatcher(victim), TriggerData( player = victim, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt index 378c3a817..ff95c5778 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -36,7 +37,7 @@ object TriggerTakeEntityDamage : Trigger("take_entity_damage") { } this.dispatch( - victim, + PlayerDispatcher(victim), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt index e740b1c95..b51c65a7e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +22,7 @@ object TriggerTameAnimal : Trigger("tame_animal") { val player = event.owner as? Player ?: return this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt index 13a746611..2634d02d2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +19,7 @@ object TriggerTeleport : Trigger("teleport") { fun handle(event: PlayerTeleportEvent) { plugin.scheduler.run { this.dispatch( - event.player, + PlayerDispatcher(event.player), TriggerData( player = event.player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt index e9177d0c5..b353c0017 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerToggleFlight : Trigger("toggle_flight") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt index 7fde1aa3f..9a5552c38 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerToggleSneak : Trigger("toggle_sneak") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt index c23ac046e..5f0b07f22 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +20,7 @@ object TriggerToggleSprint : Trigger("toggle_sprint") { val player = event.player this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt index 9740b6e59..b741003e6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.holders import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -52,7 +53,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { @Suppress("UNCHECKED_CAST") this.dispatch( - shooter, + PlayerDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt index ef28ec209..98ad8a8d0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge.triggers.impl +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +17,7 @@ object TriggerWinRaid : Trigger("win_raid") { fun handle(event: RaidFinishEvent) { for (player in event.winners) { this.dispatch( - player, + PlayerDispatcher(player), TriggerData( player = player, location = event.raid.location, From 433d6238661ba04471e61608c49cfd9a7814937c Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 14:15:41 +0000 Subject: [PATCH 02/11] Conditions are now checked against Dispatchers --- .../kotlin/com/willfp/libreforge/Holder.kt | 31 ++++++++--- .../com/willfp/libreforge/HolderProvider.kt | 5 +- .../willfp/libreforge/ProvidedHolderConfig.kt | 8 ++- .../willfp/libreforge/conditions/Condition.kt | 37 +++++++++----- .../libreforge/conditions/ConditionBlock.kt | 41 +++++++++------ .../libreforge/conditions/ConditionList.kt | 51 +++++++++++++------ .../conditions/impl/ConditionAboveBalance.kt | 12 ++++- .../impl/ConditionAboveGlobalPoints.kt | 13 ++++- .../impl/ConditionAboveHealthPercent.kt | 19 +++++-- .../impl/ConditionAboveHungerPercent.kt | 12 ++++- .../conditions/impl/ConditionAbovePoints.kt | 12 ++++- .../conditions/impl/ConditionAboveXPLevel.kt | 12 ++++- .../conditions/impl/ConditionAboveY.kt | 17 ++++++- .../conditions/impl/ConditionAnyOf.kt | 10 +++- .../conditions/impl/ConditionAtLeastOf.kt | 12 ++++- .../conditions/impl/ConditionBelowBalance.kt | 14 ++++- .../impl/ConditionBelowGlobalPoints.kt | 13 ++++- .../impl/ConditionBelowHealthPercent.kt | 19 +++++-- .../impl/ConditionBelowHungerPercent.kt | 12 ++++- .../conditions/impl/ConditionBelowPoints.kt | 12 ++++- .../conditions/impl/ConditionBelowXPLevel.kt | 12 ++++- .../conditions/impl/ConditionBelowY.kt | 14 ++++- .../impl/ConditionCanAffordPrice.kt | 7 ++- .../impl/ConditionGlobalPointsEqual.kt | 13 ++++- .../conditions/impl/ConditionHasItem.kt | 16 +++++- .../conditions/impl/ConditionHasItemData.kt | 9 +++- .../conditions/impl/ConditionHasPermission.kt | 12 ++++- .../impl/ConditionHasPotionEffect.kt | 15 +++++- .../conditions/impl/ConditionInAir.kt | 14 ++++- .../conditions/impl/ConditionInBiome.kt | 20 ++++++-- .../conditions/impl/ConditionInBlock.kt | 20 ++++++-- .../conditions/impl/ConditionInMainhand.kt | 5 +- .../conditions/impl/ConditionInOffhand.kt | 6 +-- .../conditions/impl/ConditionInWater.kt | 15 +++++- .../conditions/impl/ConditionInWorld.kt | 15 +++++- .../impl/ConditionIsExpressionTrue.kt | 12 ++++- .../conditions/impl/ConditionIsFalling.kt | 15 +++++- .../conditions/impl/ConditionIsFlying.kt | 12 ++++- .../conditions/impl/ConditionIsFrozen.kt | 15 +++++- .../conditions/impl/ConditionIsGliding.kt | 15 +++++- .../conditions/impl/ConditionIsNight.kt | 16 ++++-- .../conditions/impl/ConditionIsOp.kt | 12 ++++- .../conditions/impl/ConditionIsSneaking.kt | 14 ++++- .../conditions/impl/ConditionIsSprinting.kt | 12 ++++- .../conditions/impl/ConditionIsStorm.kt | 14 ++++- .../conditions/impl/ConditionIsSwimming.kt | 15 +++++- .../impl/ConditionItemDataEquals.kt | 11 +++- .../impl/ConditionItemLevelAbove.kt | 15 ++++-- .../impl/ConditionItemLevelBelow.kt | 13 +++-- .../impl/ConditionItemLevelEquals.kt | 14 +++-- .../impl/ConditionItemPointsAbove.kt | 11 +++- .../impl/ConditionItemPointsBelow.kt | 11 +++- .../impl/ConditionItemPointsEqual.kt | 13 +++-- .../conditions/impl/ConditionNearEntity.kt | 16 ++++-- .../conditions/impl/ConditionOnFire.kt | 15 +++++- .../conditions/impl/ConditionOnGround.kt | 16 +++++- .../impl/ConditionPlaceholderContains.kt | 19 +++++-- .../impl/ConditionPlaceholderEquals.kt | 12 ++++- .../impl/ConditionPlaceholderGreaterThan.kt | 17 +++++-- .../impl/ConditionPlaceholderLessThan.kt | 17 +++++-- .../conditions/impl/ConditionPointsEqual.kt | 16 +++++- .../conditions/impl/ConditionRidingEntity.kt | 15 +++++- .../impl/ConditionStandingOnBlock.kt | 12 ++++- .../conditions/impl/ConditionWearingBoots.kt | 5 +- .../impl/ConditionWearingChestplate.kt | 5 +- .../conditions/impl/ConditionWearingHelmet.kt | 5 +- .../impl/ConditionWearingLeggings.kt | 5 +- .../impl/ConditionWithinRadiusOf.kt | 23 ++++++--- .../conditions/templates/ItemCondition.kt | 19 +++++-- .../libreforge/counters/bind/BoundCounter.kt | 4 +- .../com/willfp/libreforge/effects/Effect.kt | 3 +- .../filters/impl/FilterVictimConditions.kt | 6 ++- .../aureliumskills/impl/ConditionHasMana.kt | 12 ++++- .../paper/impl/ConditionInBubble.kt | 15 +++++- .../paper/impl/ConditionInLava.kt | 14 ++++- .../paper/impl/ConditionInRain.kt | 15 +++++- .../worldguard/impl/ConditionInRegion.kt | 14 +++-- .../impl/ConditionalCustomPlaceholder.kt | 5 +- .../willfp/libreforge/triggers/Dispatcher.kt | 25 +++++++++ 79 files changed, 914 insertions(+), 211 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt index 2d37b24b9..343f98908 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt @@ -3,6 +3,8 @@ package com.willfp.libreforge import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.EffectList +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.NamespacedKey import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -86,25 +88,38 @@ interface ProvidedHolder { operator fun component2() = provider /** - * Get not met lines for a [player]. + * Get not met lines for a [dispatcher]. */ - fun getNotMetLines(player: Player): List { + fun getNotMetLines(dispatcher: Dispatcher<*>): List { val lines = mutableListOf() - lines += holder.conditions.getNotMetLines(player, this) - lines += holder.effects.map { it.conditions }.flatMap { it.getNotMetLines(player, this) } + lines += holder.conditions.getNotMetLines(dispatcher, this) + lines += holder.effects.map { it.conditions }.flatMap { it.getNotMetLines(dispatcher, this) } return lines } /** - * Get if the holder is showing any not met lines for a [player], or if any + * Get not met lines for a [player]. + */ + fun getNotMetLines(player: Player): List = + getNotMetLines(PlayerDispatcher(player)) + + /** + * Get if the holder is showing any not met lines for a [dispatcher], or if any * conditions are not met and have showNotMet set to true (e.g. for Enchantment Strikethrough). */ - fun isShowingAnyNotMet(player: Player): Boolean { - return holder.conditions.isShowingAnyNotMet(player, this) - || holder.effects.any { it.conditions.isShowingAnyNotMet(player, this) } + fun isShowingAnyNotMet(dispatcher: Dispatcher<*>): Boolean { + return holder.conditions.isShowingAnyNotMet(dispatcher, this) + || holder.effects.any { it.conditions.isShowingAnyNotMet(dispatcher, this) } } + + /** + * Get if the holder is showing any not met lines for a [player], or if any + * conditions are not met and have showNotMet set to true (e.g. for Enchantment Strikethrough). + */ + fun isShowingAnyNotMet(player: Player): Boolean = + isShowingAnyNotMet(PlayerDispatcher(player)) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 33f3ddea3..0505aa5b5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.map.listMap import com.willfp.libreforge.effects.EffectBlock +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import org.bukkit.event.HandlerList @@ -254,7 +255,7 @@ fun Collection.getProvidedActiveEffects(player: Player): List() for (holder in this) { - if (holder.holder.conditions.areMet(player, holder)) { + if (holder.holder.conditions.areMet(PlayerDispatcher(player), holder)) { blocks += ProvidedEffectBlocks(holder, holder.getActiveEffects(player)) } } @@ -266,7 +267,7 @@ fun Collection.getProvidedActiveEffects(player: Player): List): Config = ProvidedHolderConfig(this, providedHolder).apply { - injectPlaceholders(*providedHolder.generatePlaceholders(player).mapToPlaceholders()) + dispatcher.ifType { + injectPlaceholders(*providedHolder.generatePlaceholders(it).mapToPlaceholders()) + } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt index 39df350a0..84fcf665a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt @@ -4,6 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.Compilable import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.entity.Player import org.bukkit.event.Listener @@ -32,13 +34,24 @@ abstract class Condition( } /** - * Get if the condition is met. - * - * @param player The player. - * @param config The config. - * @param compileData The compile data. - * @return If met. + * Get if the condition is met for a [dispatcher], with a [config], [holder], and [compileData]. */ + open fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: T + ): Boolean { + return true + } + + /** + * Get if the condition is met for a [player], with a [config], and [compileData]. + */ + @Deprecated( + "Use isMet(dispatcher, config, holder, compileData) instead.", + ReplaceWith("true") + ) open fun isMet( player: Player, config: Config, @@ -48,14 +61,12 @@ abstract class Condition( } /** - * Get if the condition is met. - * - * @param player The player. - * @param config The config. - * @param holder The provided holder. - * @param compileData The compile data. - * @return If met. + * Get if the condition is met for a [player], with a [config], [holder], and [compileData]. */ + @Deprecated( + "Use isMet(dispatcher, config, holder, compileData) instead.", + ReplaceWith("true") + ) open fun isMet( player: Player, config: Config, diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt index be40d0da3..3e497935a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt @@ -10,6 +10,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.EffectList import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.get import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -37,13 +38,10 @@ class ConditionBlock internal constructor( .expireAfterAccess(10, TimeUnit.SECONDS) .build() + /** + * Check if the condition is met for a [dispatcher]. + */ fun isMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean { - val player = dispatcher.get() ?: return false - - return isMet(player, holder) - } - - fun isMet(player: Player, holder: ProvidedHolder): Boolean { /* Conditions are not thread-safe, so we must run them on the main thread. @@ -57,28 +55,41 @@ class ConditionBlock internal constructor( If the value isn't cached, then submit a task to cache it to avoid desync. */ - if (!syncMetCache.asMap().containsKey(player.uniqueId)) { + if (!syncMetCache.asMap().containsKey(dispatcher.uuid)) { plugin.scheduler.run { // Double check that it isn't cached by the time we run - if (!syncMetCache.asMap().containsKey(player.uniqueId)) { - syncMetCache.put(player.uniqueId, isMet(player, holder)) + if (!syncMetCache.asMap().containsKey(dispatcher.uuid)) { + syncMetCache.put(dispatcher.uuid, isMet(dispatcher, holder)) } } } - return syncMetCache.getIfPresent(player.uniqueId) + return syncMetCache.getIfPresent(dispatcher.uuid) ?: plugin.configYml.getBool("conditions.default-state-off-main-thread") } - val withHolder = config.applyHolder(holder, player) + val withHolder = config.applyHolder(holder, dispatcher) + + val dispatcherMet = condition.isMet(dispatcher, withHolder, holder, compileData) - val metWith = condition.isMet(player, withHolder, holder, compileData) - val metWithout = condition.isMet(player, withHolder, compileData) + // Support for legacy conditions + @Suppress("DEPRECATION") + val metWith = dispatcher.get()?.let { condition.isMet(it, withHolder, holder, compileData) } ?: true + @Suppress("DEPRECATION") + val metWithout = dispatcher.get()?.let { condition.isMet(it, withHolder, compileData) } ?: true - val isMet = (metWith && metWithout) xor isInverted + val isMet = (metWith && metWithout && dispatcherMet) xor isInverted - syncMetCache.put(player.uniqueId, isMet) + syncMetCache.put(dispatcher.uuid, isMet) return isMet } + + @Deprecated( + "Use isMet(dispatcher, holder) instead", + ReplaceWith("isMet(dispatcher, holder)"), + DeprecationLevel.ERROR + ) + fun isMet(player: Player, holder: ProvidedHolder): Boolean = + isMet(PlayerDispatcher(player), holder) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt index 1a76841b7..b85e9bee7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.triggers.Dispatcher import com.willfp.libreforge.triggers.GlobalDispatcher.dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player @@ -20,17 +21,9 @@ class ConditionList( /** * Get if all conditions are met. */ - fun areMet(player: Player, holder: ProvidedHolder): Boolean = - this.all { it.isMet(player, holder) } - - /** - * Get if all conditions are met. - */ - fun areMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean { - val player = dispatcher.get() ?: return false + fun areMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean = + this.all { it.isMet(dispatcher, holder) } - return this.all { it.isMet(player, holder) } - } /** * Get if all conditions are met, triggering effects if not. */ @@ -48,17 +41,45 @@ class ConditionList( /** * Get if any conditions are not met and should be shown. */ - fun isShowingAnyNotMet(player: Player, holder: ProvidedHolder): Boolean = - this.any { it.showNotMet && !it.isMet(player, holder) } + fun isShowingAnyNotMet(dispatcher: Dispatcher<*>, holder: ProvidedHolder): Boolean = + this.any { it.showNotMet && !it.isMet(dispatcher, holder) } /** * Get all not met lines. */ - fun getNotMetLines(player: Player, holder: ProvidedHolder): List = + fun getNotMetLines(dispatcher: Dispatcher<*>, holder: ProvidedHolder): List = this.filter { it.notMetLines.isNotEmpty() } - .filter { !it.isMet(player, holder) } + .filter { !it.isMet(dispatcher, holder) } .flatMap { it.notMetLines } - .map { it.formatEco(player, formatPlaceholders = true) } + .map { it.formatEco(dispatcher.get(), formatPlaceholders = true) } + + + @Deprecated( + "Use areMet(dispatcher, holder) instead.", + ReplaceWith("areMet(dispatcher, holder)"), + DeprecationLevel.ERROR + ) + fun areMet(player: Player, holder: ProvidedHolder): Boolean = + areMet(PlayerDispatcher(player), holder) + + /** + * Get if any conditions are not met and should be shown. + */ + @Deprecated( + "Use isShowingAnyNotMet(dispatcher, holder) instead.", + ReplaceWith("isShowingAnyNotMet(dispatcher, holder)"), + DeprecationLevel.ERROR + ) + fun isShowingAnyNotMet(player: Player, holder: ProvidedHolder): Boolean = + isShowingAnyNotMet(PlayerDispatcher(player), holder) + + @Deprecated( + "Use getNotMetLines(dispatcher, holder) instead.", + ReplaceWith("getNotMetLines(dispatcher, holder)"), + DeprecationLevel.ERROR + ) + fun getNotMetLines(player: Player, holder: ProvidedHolder): List = + getNotMetLines(PlayerDispatcher(player), holder) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt index b4bf20592..7b9e7b019 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt @@ -3,8 +3,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.economy.EconomyManager import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionAboveBalance : Condition("above_balance") { @@ -12,7 +15,14 @@ object ConditionAboveBalance : Condition("above_balance") { require("balance", "You must specify the minimum balance!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return EconomyManager.hasAmount(player, config.getDoubleFromExpression("balance", player)) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt index 79859caa5..9674d618d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionAboveGlobalPoints : Condition("above_global_points") { @@ -13,7 +16,13 @@ object ConditionAboveGlobalPoints : Condition("above_global_point require("amount", "You must specify the minimum amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return globalPoints[config.getString("type")] >= config.getDoubleFromExpression("amount", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + return globalPoints[config.getString("type")] >= + config.getDoubleFromExpression("amount", dispatcher.get()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt index 43dba28f9..3cc7b9504 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt @@ -2,10 +2,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -17,11 +21,18 @@ object ConditionAboveHealthPercent : Condition("above_health_perc require("percent", "You must specify the health percentage!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value ?: return false - val health = player.health + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val livingEntity = dispatcher.get() ?: return false - return health / maxHealth >= config.getDoubleFromExpression("percent", player) / 100 + val maxHealth = livingEntity.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value ?: return false + val health = livingEntity.health + + return health / maxHealth >= config.getDoubleFromExpression("percent", livingEntity as? Player) / 100 } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt index aee3af57f..7ec945f4b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -16,7 +19,14 @@ object ConditionAboveHungerPercent : Condition("above_hunger_perc require("percent", "You must specify the hunger percentage!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.foodLevel / 20 >= config.getDoubleFromExpression("percent", player) / 100 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt index 20dfbfeee..d7cf167c7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionAbovePoints : Condition("above_points") { @@ -13,7 +16,14 @@ object ConditionAbovePoints : Condition("above_points") { require("amount", "You must specify the minimum amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.points[config.getString("type")] >= config.getDoubleFromExpression("amount", player) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt index a1685a1e3..72f18994a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -16,7 +19,14 @@ object ConditionAboveXPLevel : Condition("above_xp_level") { require("level", "You must specify the xp level!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.level >= config.getIntFromExpression("level", player) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt index 74609fbbc..bb8bd08f9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt @@ -2,8 +2,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.triggers.ifType +import org.bukkit.block.Block +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionAboveY : Condition("above_y") { @@ -11,7 +17,14 @@ object ConditionAboveY : Condition("above_y") { require("y", "You must specify the y level!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.location.y >= config.getDoubleFromExpression("y", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + + return location.y >= config.getDoubleFromExpression("y", dispatcher.get()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt index 0cabaf44e..25328d2ad 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt @@ -7,6 +7,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.entity.Player object ConditionAnyOf : Condition("any_of") { @@ -14,8 +15,13 @@ object ConditionAnyOf : Condition("any_of") { require("conditions", "You must specify the conditions that can be met!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: ConditionList): Boolean { - return compileData.any { it.isMet(player, holder) } + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: ConditionList + ): Boolean { + return compileData.any { it.isMet(dispatcher, holder) } } override fun makeCompileData(config: Config, context: ViolationContext): ConditionList { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt index 73b458318..2efb5e1cb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt @@ -7,6 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionAtLeastOf : Condition("at_least_of") { @@ -15,8 +17,14 @@ object ConditionAtLeastOf : Condition("at_least_of") { require("amount", "You must specify the minimum amount of conditions to meet!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: ConditionList): Boolean { - return compileData.count { it.isMet(player, holder) } >= config.getIntFromExpression("amount", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: ConditionList + ): Boolean { + return compileData.count { it.isMet(dispatcher, holder) } >= + config.getIntFromExpression("amount", dispatcher.get()) } override fun makeCompileData(config: Config, context: ViolationContext): ConditionList { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt index 51dc91990..a6573d59e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt @@ -3,8 +3,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.economy.EconomyManager import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionBelowBalance : Condition("below_balance") { @@ -12,7 +15,14 @@ object ConditionBelowBalance : Condition("below_balance") { require("balance", "You must specify the maximum balance!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return !EconomyManager.hasAmount(player, config.getDoubleFromExpression("balance", player)) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + + return EconomyManager.hasAmount(player, config.getDoubleFromExpression("balance", player)) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt index 7f012bdc8..d04df983e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionBelowGlobalPoints : Condition("below_global_points") { @@ -13,7 +16,13 @@ object ConditionBelowGlobalPoints : Condition("below_global_point require("amount", "You must specify the maximum amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return globalPoints[config.getString("type")] < config.getDoubleFromExpression("amount", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + return globalPoints[config.getString("type")] < + config.getDoubleFromExpression("amount", dispatcher.get()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt index ebb67c09d..3074d9890 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt @@ -2,10 +2,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -17,11 +21,18 @@ object ConditionBelowHealthPercent : Condition("below_health_perc require("percent", "You must specify the health percentage!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value ?: return false - val health = player.health + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val livingEntity = dispatcher.get() ?: return false - return health / maxHealth <= config.getDoubleFromExpression("percent", player) / 100 + val maxHealth = livingEntity.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value ?: return false + val health = livingEntity.health + + return health / maxHealth <= config.getDoubleFromExpression("percent", livingEntity as? Player) / 100 } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt index 0e0efc58d..265403cb9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -16,7 +19,14 @@ object ConditionBelowHungerPercent : Condition("below_hunger_perc require("percent", "You must specify the hunger percentage!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.foodLevel / 20 <= config.getDoubleFromExpression("percent", player) / 100 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt index 9e5c9a945..1c0ab8f41 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionBelowPoints : Condition("below_points") { @@ -13,7 +16,14 @@ object ConditionBelowPoints : Condition("below_points") { require("amount", "You must specify the maximum amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.points[config.getString("type")] < config.getDoubleFromExpression("amount", player) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt index 00f236d8e..147314323 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -16,7 +19,14 @@ object ConditionBelowXPLevel : Condition("below_xp_level") { require("level", "You must specify the xp level!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.level < config.getIntFromExpression("level", player) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt index cd4a61dae..22a59c076 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt @@ -2,8 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionBelowY : Condition("below_y") { @@ -11,7 +15,13 @@ object ConditionBelowY : Condition("below_y") { require("y", "You must specify the y level!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.location.y < config.getDoubleFromExpression("y", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + return location.y < config.getDoubleFromExpression("y", dispatcher.get()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt index 3f7a072de..a74759ec4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt @@ -3,10 +3,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.price.Price import com.willfp.eco.core.price.Prices +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.toPlaceholderContext +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionCanAffordPrice : Condition("can_afford_price") { @@ -15,7 +18,9 @@ object ConditionCanAffordPrice : Condition("can_afford_price") { require("type", "You must specify the type of price (coins, xpl, etc.)!") } - override fun isMet(player: Player, config: Config, compileData: Price): Boolean { + override fun isMet(dispatcher: Dispatcher<*>, config: Config, holder: ProvidedHolder, compileData: Price): Boolean { + val player = dispatcher.get() ?: return false + return compileData.canAfford(player) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt index cb049047b..4c4814e94 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionGlobalPointsEqual : Condition("global_points_equal") { @@ -13,7 +16,13 @@ object ConditionGlobalPointsEqual : Condition("global_points_equa require("amount", "You must specify the amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return globalPoints[config.getString("type")] == config.getDoubleFromExpression("amount", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + return globalPoints[config.getString("type")] == + config.getDoubleFromExpression("amount", dispatcher.get()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItem.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItem.kt index 7f0e8e7ce..ab7bec1ec 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItem.kt @@ -1,11 +1,23 @@ package com.willfp.libreforge.conditions.impl import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionHasItem : ItemCondition("has_item") { - override fun getItems(player: Player): Collection { - return player.inventory.contents.toList() + override fun getItems(entity: LivingEntity): Collection { + if (entity is Player) { + return entity.inventory.contents.toList() + } + + return listOf( + entity.equipment?.helmet, + entity.equipment?.chestplate, + entity.equipment?.leggings, + entity.equipment?.boots, + entity.equipment?.itemInMainHand, + entity.equipment?.itemInOffHand + ) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt index 4ec214105..baf00f6b9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt @@ -7,6 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -15,7 +17,12 @@ object ConditionHasItemData : Condition("has_item_data") { require("key", "You must specify the data key!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val key = config.getString("key") diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt index 15f29b6fc..4069f1a5c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player @@ -12,7 +15,14 @@ object ConditionHasPermission : Condition("has_permission") { require("permission", "You must specify the permission!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.hasPermission(config.getString("permission")) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt index e744594d6..7185f435e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt @@ -3,8 +3,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.containsIgnoreCase import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object ConditionHasPotionEffect : Condition("has_potion_effect") { @@ -12,8 +16,15 @@ object ConditionHasPotionEffect : Condition("has_potion_effect") require("effect", "You must specify the potion effect!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.activePotionEffects.map { it.type.name }.containsIgnoreCase( + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val livingEntity = dispatcher.get() ?: return false + + return livingEntity.activePotionEffects.map { it.type.name }.containsIgnoreCase( config.getString("effect") ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt index 2106af4c0..08049a69c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt @@ -2,11 +2,21 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInAir : Condition("in_air") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.location.block.isEmpty == (config.getBoolOrNull("in_air") ?: true) // Legacy support + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + return location.block.isEmpty } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt index 6cb46d2c6..2d8a4126f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt @@ -2,8 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInBiome : Condition("in_biome") { @@ -11,12 +15,18 @@ object ConditionInBiome : Condition("in_biome") { require("biomes", "You must specify the biomes!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false return config.getStrings("biomes").contains( - player.world.getBiome( - player.location.blockX, - player.location.blockY, - player.location.blockZ + location.world.getBiome( + location.blockX, + location.blockY, + location.blockZ ).name.lowercase() ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt index 4c1dd8f9a..c6bd4af84 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt @@ -2,8 +2,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object ConditionInBlock : Condition("in_block") { @@ -11,10 +16,17 @@ object ConditionInBlock : Condition("in_block") { require("block", "You must specify the block!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val world = player.world - val head = world.getBlockAt(player.eyeLocation).type - val feet = world.getBlockAt(player.eyeLocation.clone().subtract(0.0, 1.0, 0.0)).type + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + val world = entity.world + val head = world.getBlockAt(entity.eyeLocation).type + val feet = world.getBlockAt(entity.eyeLocation.clone().subtract(0.0, 1.0, 0.0)).type val block = config.getString("block") return head.name.equals(block, ignoreCase = true) || feet.name.equals(block, ignoreCase = true) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt index 0e4bc529c..019f0cf32 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionInMainhand : ItemCondition("in_mainhand") { - override fun getItems(player: Player): Collection { - return player.inventory.itemInMainHand.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.itemInMainHand.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInOffhand.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInOffhand.kt index d52238733..f58924d3a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInOffhand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInOffhand.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition -import org.bukkit.entity.Player +import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack object ConditionInOffhand : ItemCondition("in_offhand") { - override fun getItems(player: Player): Collection { - return player.inventory.itemInOffHand.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.itemInOffHand.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt index 8b04aa98f..593355deb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt @@ -2,11 +2,22 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInWater : Condition("in_water") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isInWater == (config.getBoolOrNull("in_water") ?: true) // Legacy support + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isInWater } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt index 586c2f410..9c50e66f6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt @@ -2,8 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInWorld : Condition("in_world") { @@ -11,7 +15,14 @@ object ConditionInWorld : Condition("in_world") { require("world", "You must specify the world name!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.world.name.equals(config.getString("world"), ignoreCase = true) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + + return location.world.name.equals(config.getString("world"), ignoreCase = true) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt index e5b623318..11376b5d5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionIsExpressionTrue : Condition("is_expression_true") { @@ -11,7 +14,14 @@ object ConditionIsExpressionTrue : Condition("is_expression_true" require("expression", "You must specify the expression!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() + return config.getDoubleFromExpression("expression", player) == 1.0 } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt index c1eff886f..490558e97 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt @@ -2,11 +2,22 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionIsFalling : Condition("is_falling") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.velocity.y < -0.1 + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.velocity.y < -0.1 } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt index 4f498ef73..bf9c8ac0b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt @@ -2,11 +2,21 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionIsFlying : Condition("is_flying") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.isFlying } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt index 75eee2d91..a2e05b6c1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt @@ -2,11 +2,22 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object ConditionIsFrozen : Condition("is_frozen") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isFrozen + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isFrozen } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt index e4f28d989..d3be28281 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt @@ -2,16 +2,27 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityToggleGlideEvent object ConditionIsGliding : Condition("is_gliding") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isGliding == (config.getBoolOrNull("is_gliding") ?: true) // Legacy + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isGliding } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt index 37416c146..f8c92a75d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt @@ -2,13 +2,21 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionIsNight : Condition("is_night") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val isNight = player.world.time in 12301..23849 - - return isNight == (config.getBoolOrNull("is_night") ?: true) // Legacy + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + return location.world.time in 12301..23849 } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt index b88469cfe..24c6ef8ab 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt @@ -2,11 +2,21 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionIsOp : Condition("is_op") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.isOp } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt index bfeeb3eda..c7694aa32 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt @@ -2,7 +2,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -10,8 +13,15 @@ import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerToggleSneakEvent object ConditionIsSneaking : Condition("is_sneaking") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isSneaking == (config.getBoolOrNull("is_sneaking") ?: true) // Legacy + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + + return player.isSneaking } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt index 230301887..b0953e64a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt @@ -2,7 +2,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -10,7 +13,14 @@ import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerToggleSprintEvent object ConditionIsSprinting : Condition("is_sprinting") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return player.isSprinting } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt index b85370811..070ff6fc8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt @@ -2,16 +2,26 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects +import org.bukkit.entity.Entity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.weather.WeatherChangeEvent object ConditionIsStorm: Condition("is_storm") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.world.hasStorm() == (config.getBoolOrNull("is_storm") ?: true) // Legacy + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + return location.world.hasStorm() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt index c6fa08de3..fd1a60cff 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt @@ -2,16 +2,27 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityToggleSwimEvent object ConditionIsSwimming : Condition("is_swimming") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isSwimming + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isSwimming } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt index 372612077..da3cb82f3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt @@ -10,6 +10,8 @@ import com.willfp.libreforge.getFormattedString import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -19,10 +21,15 @@ object ConditionItemDataEquals : Condition("item_data_equals") { require("value", "You must specify the data value to equal!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val key = config.getString("key") - val value = config.getFormattedString("value", placeholderContext(player = player)) + val value = config.getFormattedString("value", placeholderContext(player = dispatcher.get())) return item.itemData[key] == value } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt index a808a5041..51ed0584b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt @@ -1,6 +1,8 @@ package com.willfp.libreforge.conditions.impl +import com.gamingmesh.jobs.commands.list.level import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments @@ -8,6 +10,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -17,11 +21,16 @@ object ConditionItemLevelAbove : Condition("item_level_above") { require("level", "You must specify the minimum level!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val type = LevelTypes[config.getString("id")] - val level = config.getIntFromExpression("level", player) + val level = config.getIntFromExpression("level", dispatcher.get()) - return item.levels[type].level >= level + return item.levels[type].level > level } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt index 3d489de05..9cbfdea35 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -17,11 +19,16 @@ object ConditionItemLevelBelow : Condition("item_level_below") { require("level", "You must specify the maximum level!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val type = LevelTypes[config.getString("id")] - val level = config.getIntFromExpression("level", player) + val level = config.getIntFromExpression("level", dispatcher.get()) - return item.levels[type].level <= level + return item.levels[type].level < level } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt index 6c71353c3..83ea81a7e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -17,11 +19,15 @@ object ConditionItemLevelEquals : Condition("item_level_equals") require("level", "You must specify the level!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false - val type = LevelTypes[config.getString("id")] - - val level = config.getIntFromExpression("level", player) + val type = LevelTypes[config.getString("name")] + val level = config.getIntFromExpression("level", dispatcher.get()) return item.levels[type].level == level } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt index fa347edd2..da1264308 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt @@ -7,6 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -16,10 +18,15 @@ object ConditionItemPointsAbove : Condition("item_points_above") require("amount", "You must specify minimum amount of points!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val type = config.getString("type") - val amount = config.getDoubleFromExpression("type", player) + val amount = config.getDoubleFromExpression("type", dispatcher.get()) return item.points[type] >= amount } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt index d0efe7de9..cf94622b5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt @@ -7,6 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -16,10 +18,15 @@ object ConditionItemPointsBelow : Condition("item_points_below") require("amount", "You must specify maximum amount of points!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val type = config.getString("type") - val amount = config.getDoubleFromExpression("type", player) + val amount = config.getDoubleFromExpression("type", dispatcher.get()) return item.points[type] <= amount } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt index 46361aacb..b27754c41 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt @@ -7,6 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -16,11 +18,16 @@ object ConditionItemPointsEqual : Condition("item_points_equal") require("amount", "You must specify the amount of points!") } - override fun isMet(player: Player, config: Config, holder: ProvidedHolder, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { val item = holder.getProvider() ?: return false val type = config.getString("type") - val amount = config.getDoubleFromExpression("type", player) + val amount = config.getDoubleFromExpression("type", dispatcher.get()) - return (item.points[type] - amount) < 0.0001 // Floating point error. + return item.points[type] == amount } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt index 79e84f646..bffe334f0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt @@ -4,9 +4,13 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity import com.willfp.eco.core.entities.impl.EmptyTestableEntity +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionNearEntity : Condition>("near_entity") { @@ -15,10 +19,16 @@ object ConditionNearEntity : Condition>("near_entity" require("radius", "You must specify the radius!") } - override fun isMet(player: Player, config: Config, compileData: Collection): Boolean { - val radius = config.getDoubleFromExpression("radius", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: Collection + ): Boolean { + val location = dispatcher.location ?: return false + val radius = config.getDoubleFromExpression("radius", dispatcher.get()) - return player.getNearbyEntities(radius, radius, radius).any { + return location.world.getNearbyEntities(location, radius, radius, radius).any { compileData.any { test -> test.matches(it) } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt index cc994a1f6..eec2dc2b4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt @@ -2,16 +2,27 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects +import org.bukkit.entity.Entity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityDamageEvent object ConditionOnFire : Condition("on_fire") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return (player.fireTicks > 0) == (config.getBoolOrNull("on_fire") ?: true) // Legacy + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.fireTicks > 0 } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt index a01d3ab72..a7f27e359 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt @@ -2,11 +2,23 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.getProvider +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.block.BlockFace +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionOnGround : Condition("on_ground") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.world.getBlockAt(player.location.clone().add(0.0, -1.0, 0.0)).isSolid + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + return location.block.getRelative(BlockFace.SOUTH).isSolid } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt index 6452db0cb..bf68b82a5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt @@ -3,8 +3,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.getProvider +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionPlaceholderContains : Condition("placeholder_contains") { @@ -12,9 +16,18 @@ object ConditionPlaceholderContains : Condition("placeholder_cont require("placeholder", "You must specify the placeholder!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() + return config.getFormattedString("placeholder", placeholderContext(player = player)) - .contains(config.getFormattedString("value", placeholderContext(player = player)), - ignoreCase = config.getBool("ignore_case")) + .contains( + config.getFormattedString("value", placeholderContext(player = player)), + ignoreCase = config.getBool("ignore_case") + ) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt index ea7cf3437..0d755df52 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt @@ -3,8 +3,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player @@ -14,7 +17,14 @@ object ConditionPlaceholderEquals : Condition("placeholder_equals require("value", "You must specify the value!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() + return config.getFormattedString("placeholder", placeholderContext(player = player)) .equals(config.getFormattedString("value", placeholderContext(player = player)), ignoreCase = config.getBool("ignore_case")) diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt index 48892cf2e..5d71c9cf0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt @@ -3,8 +3,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player @@ -14,9 +17,15 @@ object ConditionPlaceholderGreaterThan : Condition("placeholder_g require("value", "You must specify the value!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val value = config.getFormattedString("placeholder", placeholderContext(player = player)) - .toDoubleOrNull() ?: 0.0 - return value >= config.getDoubleFromExpression("value", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() + + return (config.getFormattedString("placeholder", placeholderContext(player = player)) + .toDoubleOrNull() ?: 0.0) > config.getDoubleFromExpression("value", player) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt index c2d343657..4365825bc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt @@ -3,8 +3,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player @@ -14,9 +17,15 @@ object ConditionPlaceholderLessThan : Condition("placeholder_less require("value", "You must specify the value!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val value = config.getFormattedString("placeholder", placeholderContext(player = player)) - .toDoubleOrNull() ?: 0.0 - return value < config.getDoubleFromExpression("value", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() + + return (config.getFormattedString("placeholder", placeholderContext(player = player)) + .toDoubleOrNull() ?: 0.0) < config.getDoubleFromExpression("value", player) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt index 5f871a307..33906b692 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt @@ -2,9 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionPointsEqual : Condition("points_equal") { @@ -13,7 +16,16 @@ object ConditionPointsEqual : Condition("points_equal") { require("amount", "You must specify the amount of points!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.points[config.getString("type")] == config.getDoubleFromExpression("amount", player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + val type = config.getString("type") + val amount = config.getDoubleFromExpression("amount", player) + + return player.points[type] == amount } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt index cc3497d84..05fe07be3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt @@ -3,10 +3,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects +import org.bukkit.entity.Entity import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -18,8 +22,15 @@ object ConditionRidingEntity : Condition>("riding_ent require("entities", "You must specify the list of allowed entities!") } - override fun isMet(player: Player, config: Config, compileData: Collection): Boolean { - return compileData.any { it.matches(player.vehicle) } + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: Collection + ): Boolean { + val entity = dispatcher.get() ?: return false + + return compileData.any { it.matches(entity.vehicle) } } override fun makeCompileData(config: Config, context: ViolationContext): Collection { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt index b00651c70..f311d13a0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt @@ -2,8 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object ConditionStandingOnBlock : Condition("standing_on_block") { @@ -11,7 +14,14 @@ object ConditionStandingOnBlock : Condition("standing_on_block") require("block", "You must specify the type of block!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + val tests = setOf( player.location.block, player.location.clone().add(0.0, -1.0, 0.0).block diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt index f6ae81cdf..08be85ed5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingBoots : ItemCondition("wearing_boots") { - override fun getItems(player: Player): Collection { - return player.inventory.boots.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.boots.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt index 151f7213a..f06d56ed1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingChestplate : ItemCondition("wearing_chestplate") { - override fun getItems(player: Player): Collection { - return player.inventory.chestplate.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.chestplate.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt index 17593ce62..afe933118 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingHelmet : ItemCondition("wearing_helmet") { - override fun getItems(player: Player): Collection { - return player.inventory.helmet.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.helmet.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt index 7016ab816..661274677 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingLeggings : ItemCondition("wearing_leggings") { - override fun getItems(player: Player): Collection { - return player.inventory.leggings.toSingletonList() + override fun getItems(entity: LivingEntity): Collection { + return entity.equipment?.leggings.toSingletonList() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt index dae9f43a6..d38df1f11 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt @@ -2,8 +2,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player import org.bukkit.util.Vector import kotlin.math.pow @@ -16,15 +20,22 @@ object ConditionWithinRadiusOf : Condition("within_radius_of") { require("radius", "You must specify the radius!") } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + val vector = Vector( - config.getDoubleFromExpression("x", player), - config.getDoubleFromExpression("y", player), - config.getDoubleFromExpression("z", player) + config.getDoubleFromExpression("x", dispatcher.get()), + config.getDoubleFromExpression("y", dispatcher.get()), + config.getDoubleFromExpression("z", dispatcher.get()) ) - val dist = config.getDoubleFromExpression("radius", player).pow(2) + val dist = config.getDoubleFromExpression("radius", dispatcher.get()).pow(2) - return player.location.toVector().distanceSquared(vector) <= dist + return location.toVector().distanceSquared(vector) <= dist } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt index 908d9f7a3..cdb6adfe6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt @@ -4,12 +4,15 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.TestableItem import com.willfp.eco.core.recipe.parts.EmptyTestableItem +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.filterNotEmpty import com.willfp.libreforge.getStrings -import org.bukkit.entity.Player +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack abstract class ItemCondition(id: String) : Condition>(id) { @@ -17,10 +20,18 @@ abstract class ItemCondition(id: String) : Condition>(i require(listOf("items", "item"), "You must specify the items!") } - override fun isMet(player: Player, config: Config, compileData: Collection) = - getItems(player) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: Collection + ): Boolean { + val entity = dispatcher.get() ?: return false + + return getItems(entity) .filterNotEmpty() .any { compileData.any { test -> test.matches(it) } } + } override fun makeCompileData(config: Config, context: ViolationContext): Collection { return config.getStrings("items", "item") @@ -29,5 +40,5 @@ abstract class ItemCondition(id: String) : Condition>(i .filterNot { it is EmptyTestableItem } } - abstract fun getItems(player: Player): Collection + abstract fun getItems(entity: LivingEntity): Collection } diff --git a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt index 9dbf55220..168d21be0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt @@ -30,11 +30,11 @@ internal data class BoundCounter( return } - if (!counter.conditions.areMet(player, data.holder)) { + if (!counter.filters.isMet(data)) { return } - if (!counter.filters.isMet(data)) { + if (!counter.conditions.areMetAndTrigger(trigger)) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt index 55adcd718..2594a430a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt @@ -9,6 +9,7 @@ import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.mutators.emptyMutatorList import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -84,7 +85,7 @@ abstract class Effect( effectCounter[player.uniqueId]++ val count = effectCounter[player.uniqueId] - val withHolder = config.config.applyHolder(holder, player) + val withHolder = config.config.applyHolder(holder, PlayerDispatcher(player)) onEnable(player, withHolder, identifierFactory.makeIdentifiers(count), holder, config.compileData) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt index 2b23c3dbd..634350354 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt @@ -5,6 +5,8 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.filters.Filter +import com.willfp.libreforge.triggers.EntityDispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.entity.Player @@ -14,9 +16,9 @@ object FilterVictimConditions : Filter>("victi } override fun isMet(data: TriggerData, value: Collection, compileData: ConditionList): Boolean { - val victim = data.victim as? Player ?: return true + val victim = data.victim ?: return false - return compileData.areMet(victim, data.holder) + return compileData.areMet(EntityDispatcher(victim), data.holder) } override fun makeCompileData(config: Config, context: ViolationContext, values: Collection): ConditionList { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt index 4effdc78a..0bb21162f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt @@ -4,8 +4,11 @@ import com.archyx.aureliumskills.api.AureliumAPI import com.archyx.aureliumskills.api.event.ManaRegenerateEvent import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -23,7 +26,14 @@ object ConditionHasMana : Condition("has_mana") { player.updateEffects() } - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val player = dispatcher.get() ?: return false + return AureliumAPI.getMana(player) > config.getDoubleFromExpression("amount", player) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt index 09771cf6d..bd5464180 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt @@ -2,11 +2,22 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInBubble : Condition("in_bubble") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isInBubbleColumn + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isInBubbleColumn } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt index 6605bc1ba..b17c09ce9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt @@ -2,11 +2,21 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInLava : Condition("in_lava") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isInLava + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + return entity.isInLava } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt index 1fb965b9b..186a3b4c0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt @@ -2,11 +2,22 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get +import org.bukkit.entity.Entity import org.bukkit.entity.Player object ConditionInRain : Condition("in_rain") { - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - return player.isInRain + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val entity = dispatcher.get() ?: return false + + return entity.isInRain } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt index 04e51a779..d2e2ca5dc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt @@ -6,8 +6,10 @@ import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.containsIgnoreCase import com.willfp.libreforge.NoCompileData +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.entity.Player object ConditionInRegion : Condition("in_region") { @@ -17,9 +19,15 @@ object ConditionInRegion : Condition("in_region") { private val regionContainer = WorldGuard.getInstance().platform.regionContainer - override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean { - val world = BukkitAdapter.adapt(player.world) - val block = BlockVector3.at(player.location.x, player.location.y, player.location.z) + override fun isMet( + dispatcher: Dispatcher<*>, + config: Config, + holder: ProvidedHolder, + compileData: NoCompileData + ): Boolean { + val location = dispatcher.location ?: return false + val world = BukkitAdapter.adapt(location.world) + val block = BlockVector3.at(location.x, location.y, location.z) val manager = regionContainer[world] ?: return false val inRegions = manager.getApplicableRegionsIDs(block).map { it.lowercase() }.toSet() diff --git a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt index bde1666f8..22af40a6a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt @@ -11,11 +11,12 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.placeholders.CustomPlaceholder +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.inventory.ItemStack class ConditionalCustomPlaceholder( id: String, - private val config: Config, + config: Config, plugin: EcoPlugin ) : CustomPlaceholder(id) { private val defaultExpr = config.getStringOrNull("default") @@ -39,7 +40,7 @@ class ConditionalCustomPlaceholder( val holder = BlankItemHolder(ctx.itemStack) val value = values - .firstOrNull { it.conditions.areMet(player, holder) } + .firstOrNull { it.conditions.areMet(PlayerDispatcher(player), holder) } ?.expr ?: return defaultExpr?.let { parseValue(it, ctx) } return parseValue(value, ctx) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt index 82a21c806..80151ee08 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt @@ -1,6 +1,9 @@ package com.willfp.libreforge.triggers +import org.bukkit.Location +import org.bukkit.entity.Entity import org.bukkit.entity.Player +import java.util.Locale import java.util.UUID /** @@ -16,6 +19,11 @@ interface Dispatcher { * The dispatcher itself. */ val dispatcher: T + + /** + * The location of the dispatcher. + */ + val location: Location? } /** @@ -48,6 +56,22 @@ class PlayerDispatcher( ) : Dispatcher { override val uuid get() = dispatcher.uniqueId + + override val location + get() = dispatcher.location +} + +/** + * A dispatcher for an entity. + */ +class EntityDispatcher( + override val dispatcher: Entity +) : Dispatcher { + override val uuid + get() = dispatcher.uniqueId + + override val location + get() = dispatcher.location } /** @@ -56,4 +80,5 @@ class PlayerDispatcher( object GlobalDispatcher : Dispatcher { override val uuid = UUID(0, 0) override val dispatcher = Unit + override val location = null } From a2a7eaa54d21873461f095fabefc12a6daa6d34a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 14:46:12 +0000 Subject: [PATCH 03/11] Effects are now enabled and disabled by Dispatchers --- .../willfp/libreforge/EffectCollisionFixer.kt | 3 +- .../com/willfp/libreforge/HolderProvider.kt | 10 +- .../willfp/libreforge/effects/ChainElement.kt | 37 +++++- .../com/willfp/libreforge/effects/Effect.kt | 108 +++++++++++++----- .../willfp/libreforge/effects/EffectBlock.kt | 37 +++++- .../willfp/libreforge/effects/ElementLike.kt | 4 +- .../willfp/libreforge/effects/RichChain.kt | 2 +- .../effects/events/EffectDisableEvent.kt | 15 ++- .../effects/events/EffectEnableEvent.kt | 15 ++- .../impl/EffectAddPermanentHolderInRadius.kt | 16 ++- .../effects/impl/EffectAddPoints.kt | 16 ++- .../libreforge/effects/impl/EffectArmor.kt | 5 +- .../effects/impl/EffectArmorToughness.kt | 5 +- .../impl/EffectAttackSpeedMultiplier.kt | 5 +- .../effects/impl/EffectBlockCommands.kt | 11 +- .../effects/impl/EffectBonusHealth.kt | 11 +- .../effects/impl/EffectBrewTimeMultiplier.kt | 3 +- .../impl/EffectDontConsumeLapisChance.kt | 3 +- .../effects/impl/EffectDontConsumeXpChance.kt | 3 +- .../effects/impl/EffectFeatherStep.kt | 9 +- .../libreforge/effects/impl/EffectFlight.kt | 16 ++- .../effects/impl/EffectFoodMultiplier.kt | 3 +- .../effects/impl/EffectHungerMultiplier.kt | 10 +- .../effects/impl/EffectKeepInventory.kt | 15 ++- .../effects/impl/EffectKnockbackMultiplier.kt | 5 +- .../EffectKnockbackResistanceMultiplier.kt | 5 +- .../effects/impl/EffectLuckMultiplier.kt | 5 +- .../impl/EffectMovementSpeedMultiplier.kt | 5 +- .../impl/EffectPermanentPotionEffect.kt | 10 +- .../impl/EffectPotionDurationMultiplier.kt | 5 +- .../effects/impl/EffectRapidBows.kt | 17 +-- .../effects/impl/EffectReelSpeedMultiplier.kt | 3 +- .../effects/impl/EffectRegenMultiplier.kt | 9 +- .../effects/impl/EffectReplantCrops.kt | 9 +- .../effects/impl/EffectSellMultiplier.kt | 3 +- .../effects/impl/EffectTelekinesis.kt | 9 +- .../effects/impl/EffectXpMultiplier.kt | 3 +- .../effects/templates/AttributeEffect.kt | 33 +++--- .../templates/ChanceMultiplierEffect.kt | 27 +++-- .../templates/MultiMultiplierEffect.kt | 39 +++++-- .../effects/templates/MultiplierEffect.kt | 31 +++-- .../aureliumskills/impl/EffectAddStat.kt | 10 +- .../impl/EffectSkillXpMultiplier.kt | 3 +- .../jobs/impl/EffectJobsMoneyMultiplier.kt | 3 +- .../jobs/impl/EffectJobsXpMultiplier.kt | 3 +- .../mcmmo/impl/EffectMcMMOXpMultiplier.kt | 3 +- .../paper/impl/EffectElytraBoostSaveChance.kt | 3 +- .../tmmobcoins/TMMobcoinsIntegration.kt | 4 +- .../impl/EffectMobCoinsMultiplier.kt | 3 +- .../vault/impl/EffectGivePermission.kt | 24 +++- 50 files changed, 451 insertions(+), 185 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt index 04e631a61..7c4110649 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge import com.willfp.libreforge.effects.Effects +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.attribute.Attribute import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -15,7 +16,7 @@ object EffectCollisionFixer : Listener { val player = event.player for ((holder, effects) in player.providedActiveEffects) { for (effect in effects) { - effect.disable(player, holder) + effect.disable(PlayerDispatcher(player), holder) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 0505aa5b5..9caa0c3f5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -305,12 +305,14 @@ fun Player.updateEffects() { val removed = (beforeF without afterF).sorted() val toReload = (afterF without added).sorted() + val dispatcher = PlayerDispatcher(this) + for ((effect, holder) in removed) { - effect.disable(this, holder) + effect.disable(dispatcher, holder) } for ((effect, holder) in added) { - effect.enable(this, holder) + effect.enable(dispatcher, holder) } // Reloading is now done by disabling all, then enabling all. Effect#reload is deprecated. @@ -318,11 +320,11 @@ fun Player.updateEffects() { // order as mixing weights is not a concern. for ((effect, holder) in toReload) { - effect.disable(this, holder, isReload = true) + effect.disable(dispatcher, holder, isReload = true) } for ((effect, holder) in toReload) { - effect.enable(this, holder, isReload = true) + effect.enable(dispatcher, holder, isReload = true) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt index f5fb27e7b..0cdfb41f3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt @@ -11,6 +11,8 @@ import com.willfp.libreforge.effects.events.EffectEnableEvent import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID @@ -35,27 +37,27 @@ class ChainElement internal constructor( val runOrder = forceRunOrder ?: effect.runOrder fun enable( - player: Player, + dispatcher: Dispatcher<*>, holder: ProvidedHolder, isReload: Boolean = false ) { if (!isReload) { - Bukkit.getPluginManager().callEvent(EffectEnableEvent(player, effect, holder)) + Bukkit.getPluginManager().callEvent(EffectEnableEvent(dispatcher, effect, holder)) } - effect.enable(player, holder, this, isReload = isReload) + effect.enable(dispatcher, holder, this, isReload = isReload) } fun disable( - player: Player, + dispatcher: Dispatcher<*>, holder: ProvidedHolder, isReload: Boolean = false ) { if (!isReload) { - Bukkit.getPluginManager().callEvent(EffectDisableEvent(player, effect, holder)) + Bukkit.getPluginManager().callEvent(EffectDisableEvent(dispatcher, effect, holder)) } - effect.disable(player, holder, isReload = isReload) + effect.disable(dispatcher, holder, isReload = isReload) } override fun doTrigger(trigger: DispatchedTrigger) = @@ -63,4 +65,27 @@ class ChainElement internal constructor( override fun shouldTrigger(trigger: DispatchedTrigger): Boolean = effect.shouldTrigger(trigger, this) + + + @Deprecated( + "Use enable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("enable(dispatcher, holder, isReload)"), + DeprecationLevel.ERROR + ) + fun enable( + player: Player, + holder: ProvidedHolder, + isReload: Boolean = false + ) = enable(PlayerDispatcher(player), holder, isReload) + + @Deprecated( + "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("disable(dispatcher, holder, isReload)"), + DeprecationLevel.ERROR + ) + fun disable( + player: Player, + holder: ProvidedHolder, + isReload: Boolean = false + ) = disable(PlayerDispatcher(player), holder, isReload) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt index 2594a430a..1ff7dd3f0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt @@ -3,17 +3,20 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.defaultMap import com.willfp.libreforge.Compilable +import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.applyHolder import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.mutators.emptyMutatorList import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import com.willfp.libreforge.triggers.Triggers +import com.willfp.libreforge.triggers.ifType import org.bukkit.entity.Player import org.bukkit.event.Listener import java.util.UUID @@ -21,7 +24,7 @@ import java.util.UUID abstract class Effect( final override val id: String ) : Compilable(), Listener { - // Maps Player UUIDs to the effect count. + // Maps Dispatcher UUIDs to the effect count. private val effectCounter = defaultMap(0) // The identifier factory. @@ -66,13 +69,10 @@ abstract class Effect( Triggers.withParameters(parameters)(trigger, mutators) /** - * Enable a permanent effect. - * - * @param player The player. - * @param config The effect config. + * Enable a permanent effect for a [dispatcher]. */ fun enable( - player: Player, + dispatcher: Dispatcher<*>, holder: ProvidedHolder, config: ChainElement, isReload: Boolean = false @@ -82,24 +82,25 @@ abstract class Effect( } // Increment first to fix reload bug where effects are applied twice. - effectCounter[player.uniqueId]++ - val count = effectCounter[player.uniqueId] + effectCounter[dispatcher.uuid]++ + val count = effectCounter[dispatcher.uuid] + + val withHolder = config.config.applyHolder(holder, dispatcher) - val withHolder = config.config.applyHolder(holder, PlayerDispatcher(player)) + onEnable(dispatcher, withHolder, identifierFactory.makeIdentifiers(count), holder, config.compileData) - onEnable(player, withHolder, identifierFactory.makeIdentifiers(count), holder, config.compileData) + // Legacy support + dispatcher.ifType { + @Suppress("DEPRECATION") + onEnable(it, withHolder, identifierFactory.makeIdentifiers(count), holder, config.compileData) + } } /** * Handle the enabling of this permanent effect. - * - * @param player The player. - * @param config The config. - * @param identifiers The identifiers. - * @param compileData The compile data. */ protected open fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, @@ -109,12 +110,10 @@ abstract class Effect( } /** - * Disable a permanent effect. - * - * @param player The player. + * Disable a permanent effect for a [dispatcher]. */ fun disable( - player: Player, + dispatcher: Dispatcher<*>, holder: ProvidedHolder, isReload: Boolean = false ) { @@ -122,22 +121,26 @@ abstract class Effect( return } - if (effectCounter[player.uniqueId] == 0) { + if (effectCounter[dispatcher.uuid] == 0) { return } - val count = effectCounter[player.uniqueId]-- - onDisable(player, identifierFactory.makeIdentifiers(count), holder) + val count = effectCounter[dispatcher.uuid]-- + + onDisable(dispatcher, identifierFactory.makeIdentifiers(count), holder) + + // Legacy support + dispatcher.ifType { + @Suppress("DEPRECATION") + onDisable(it, identifierFactory.makeIdentifiers(count), holder) + } } /** * Handle the disabling of this permanent effect. - * - * @param player The player. - * @param identifiers The identifiers. */ protected open fun onDisable( - player: Player, + dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder ) { @@ -204,4 +207,55 @@ abstract class Effect( open fun postRegister() { // Override when needed. } + + + + @Deprecated( + "Use enable(Dispatcher<*>, ProvidedHolder, ChainElement, Boolean)", + ReplaceWith("enable(dispatcher, holder, config, isReload)"), + DeprecationLevel.ERROR + ) + fun enable( + player: Player, + holder: ProvidedHolder, + config: ChainElement, + isReload: Boolean = false + ) = enable(PlayerDispatcher(player), holder, config, isReload) + + @Deprecated( + "Use enable(Dispatcher<*>, ProvidedHolder, ChainElement, Boolean)", + ReplaceWith("enable(dispatcher, holder, config, isReload)") + ) + protected open fun onEnable( + player: Player, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: T + ) { + // Override when needed. + } + + @Deprecated( + "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("disable(dispatcher, holder, isReload)"), + DeprecationLevel.ERROR + ) + fun disable( + player: Player, + holder: ProvidedHolder, + isReload: Boolean = false + ) = disable(PlayerDispatcher(player), holder, isReload) + + @Deprecated( + "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("disable(dispatcher, holder, isReload)") + ) + protected open fun onDisable( + player: Player, + identifiers: Identifiers, + holder: ProvidedHolder + ) { + // Override when needed. + } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt index d478b3319..e032ac88e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.effects.arguments.EffectArgumentList import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import com.willfp.libreforge.triggers.PotentiallyTriggerable import com.willfp.libreforge.triggers.Trigger import org.bukkit.entity.Player @@ -26,25 +28,54 @@ class EffectBlock internal constructor( override val conditions: ConditionList, override val mutators: MutatorList, override val filters: FilterList, - override val isElementOwnChain: Boolean + override val shouldDelegateExecution: Boolean ) : ElementLike(), PotentiallyTriggerable { override val supportsDelay = effects.all { it.supportsDelay } val weight = effects.weight + /** + * Enable the effects. + */ + fun enable( + dispatcher: Dispatcher<*>, + holder: ProvidedHolder, + isReload: Boolean = false + ) = effects.forEach { it.enable(dispatcher, holder, isReload = isReload) } + + /** + * Disable the effects. + */ + fun disable( + dispatcher: Dispatcher<*>, + holder: ProvidedHolder, + isReload: Boolean = false + ) = effects.forEach { it.disable(dispatcher, holder, isReload = isReload) } + + @Deprecated( + "Use enable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("enable(dispatcher, holder, isReload)"), + DeprecationLevel.ERROR + ) @JvmOverloads fun enable( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = effects.forEach { it.enable(player, holder, isReload = isReload) } + ) = enable(PlayerDispatcher(player), holder, isReload = isReload) + @Deprecated( + "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", + ReplaceWith("disable(dispatcher, holder, isReload)"), + DeprecationLevel.ERROR + ) @JvmOverloads fun disable( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = effects.forEach { it.disable(player, holder, isReload = isReload) } + ) = disable(PlayerDispatcher(player), holder, isReload = isReload) + fun tryTrigger(trigger: DispatchedTrigger) { if (canBeTriggeredBy(trigger.trigger)) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/ElementLike.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/ElementLike.kt index c1bde6bd5..2ac4be985 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/ElementLike.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/ElementLike.kt @@ -28,7 +28,7 @@ abstract class ElementLike : ConfigurableElement { /** * If the element is its own chain, (e.g. has an ID specified directly at the top level). */ - open val isElementOwnChain: Boolean = false + open val shouldDelegateExecution: Boolean = false // Inject placeholders into all config blocks. private fun injectPlaceholders(placeholders: List) { @@ -53,7 +53,7 @@ abstract class ElementLike : ConfigurableElement { */ fun trigger(trigger: DispatchedTrigger): Boolean { // If own chain, defer all to elements. - if (isElementOwnChain) { + if (shouldDelegateExecution) { return doTrigger(trigger) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt index 0845d38f5..f9b59fb71 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt @@ -26,7 +26,7 @@ class RichChain internal constructor( override val mutators: MutatorList, override val filters: FilterList ) : ElementLike() { - override val isElementOwnChain = false + override val shouldDelegateExecution = false override val supportsDelay = effects.all { it.supportsDelay } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt index 717ee3294..fe613fb2a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt @@ -2,17 +2,28 @@ package com.willfp.libreforge.effects.events import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player +import org.bukkit.event.Event import org.bukkit.event.HandlerList import org.bukkit.event.player.PlayerEvent class EffectDisableEvent( - who: Player, + val dispatcher: Dispatcher<*>, val effect: Effect<*>, val holder: ProvidedHolder -) : PlayerEvent(who) { +) : Event() { override fun getHandlers() = handlerList + @Deprecated( + "Use dispatcher.get()", + ReplaceWith("dispatcher.get()"), + DeprecationLevel.ERROR + ) + val player: Player? + get() = dispatcher.get() + companion object { private val handlerList = HandlerList() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt index cbf6aff5d..5e0552cdb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt @@ -2,17 +2,28 @@ package com.willfp.libreforge.effects.events import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player +import org.bukkit.event.Event import org.bukkit.event.HandlerList import org.bukkit.event.player.PlayerEvent class EffectEnableEvent( - who: Player, + val dispatcher: Dispatcher<*>, val effect: Effect<*>, val holder: ProvidedHolder -) : PlayerEvent(who) { +) : Event() { override fun getHandlers() = handlerList + @Deprecated( + "Use dispatcher.get()", + ReplaceWith("dispatcher.get()"), + DeprecationLevel.ERROR + ) + val player: Player? + get() = dispatcher.get() + companion object { private val handlerList = HandlerList() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt index 301620922..48d1d1aa8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt @@ -13,6 +13,8 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.Objects @@ -41,21 +43,27 @@ object EffectAddPermanentHolderInRadius : Effect("add_permanent_ } } - override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: HolderTemplate) { - val radius = config.getDoubleFromExpression("radius", player) + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: HolderTemplate + ) { + val radius = config.getDoubleFromExpression("radius", dispatcher.get()) val applyToSelf = config.getBool("apply-to-self") val nearbyHolder = PermanentNearbyHolder( compileData.toHolder(identifiers.key), radius, - player.uniqueId, + dispatcher.uuid, applyToSelf ) holders += nearbyHolder } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { holders.removeIf { it.holder.id == identifiers.key } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt index caf3f2d6b..15f484f45 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.points +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import java.util.UUID @@ -19,7 +21,15 @@ object EffectAddPoints : Effect("add_points") { private val tracker = nestedMap() - override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData) { + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { + val player = dispatcher.get() ?: return + val added = tracker[player.uniqueId] val point = config.getString("type") val amount = config.getDoubleFromExpression("amount", player) @@ -34,7 +44,9 @@ object EffectAddPoints : Effect("add_points") { tracker[player.uniqueId] = added } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val player = dispatcher.get() ?: return + val added = tracker[player.uniqueId] val addedPoint = added[identifiers.uuid] ?: return added -= identifiers.uuid diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmor.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmor.kt index 4ad612471..e282966cf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmor.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmor.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectArmor : AttributeEffect( @@ -16,6 +17,6 @@ object EffectArmor : AttributeEffect( require("points", "You must specify the amount of points to add/remove!") } - override fun getValue(config: Config, player: Player) = - config.getIntFromExpression("points", player).toDouble() + override fun getValue(config: Config, entity: LivingEntity): Double = + config.getDoubleFromExpression("points", entity as? Player) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmorToughness.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmorToughness.kt index d0f4a7ebb..8fd369eab 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmorToughness.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectArmorToughness.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectArmorToughness : AttributeEffect( @@ -16,6 +17,6 @@ object EffectArmorToughness : AttributeEffect( require("points", "You must specify the amount of points to add/remove!") } - override fun getValue(config: Config, player: Player) = - config.getIntFromExpression("points", player).toDouble() + override fun getValue(config: Config, entity: LivingEntity): Double = + config.getDoubleFromExpression("points", entity as? Player) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAttackSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAttackSpeedMultiplier.kt index 54f2cbb3b..25321c0a5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAttackSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAttackSpeedMultiplier.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectAttackSpeedMultiplier : AttributeEffect( @@ -16,6 +17,6 @@ object EffectAttackSpeedMultiplier : AttributeEffect( require("multiplier", "You must specify the attack speed multiplier!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("multiplier", player) - 1 + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("multiplier", entity as? Player) - 1 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt index c77942635..03c54df6a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerCommandPreprocessEvent @@ -22,21 +23,21 @@ object EffectBlockCommands : Effect("block_commands") { private val messages = mutableMapOf?>() override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - val commands = players[player.uniqueId] + val commands = players[dispatcher.uuid] commands[identifiers.uuid] = config.getStrings("commands") messages[identifiers.uuid] = config.getStringsOrNull("messages") - players[player.uniqueId] = commands + players[dispatcher.uuid] = commands } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - players[player.uniqueId].remove(identifiers.uuid) + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + players[dispatcher.uuid].remove(identifiers.uuid) messages.remove(identifiers.uuid) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBonusHealth.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBonusHealth.kt index 04f76a004..a73231429 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBonusHealth.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBonusHealth.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectBonusHealth : AttributeEffect( @@ -16,12 +17,12 @@ object EffectBonusHealth : AttributeEffect( require("health", "You must specify the bonus health to give!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("health", player) + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("health", entity as? Player) - override fun constrainAttribute(player: Player, value: Double) { - if (player.health > value) { - player.health = value + override fun constrainAttribute(entity: LivingEntity, value: Double) { + if (entity.health > value) { + entity.health = value } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt index be5a6bbef..6e1025b50 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.block.BrewingStand import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -14,7 +15,7 @@ object EffectBrewTimeMultiplier : MultiplierEffect("brew_time_multiplier") { fun handle(event: InventoryClickEvent) { val player = event.whoClicked as? Player ?: return - val multiplier = getMultiplier(player) + val multiplier = getMultiplier(PlayerDispatcher(player)) if (player.openInventory.topInventory.holder !is BrewingStand) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt index 95f84b78b..19b0e9e4a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.Material import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -14,7 +15,7 @@ object EffectDontConsumeLapisChance : ChanceMultiplierEffect("dont_consume_lapis val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(player)) { + if (!passesChance(PlayerDispatcher(player))) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt index 98cd8fabb..96e156497 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.enchantment.EnchantItemEvent @@ -12,7 +13,7 @@ object EffectDontConsumeXpChance : ChanceMultiplierEffect("dont_consume_xp_chanc val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(player)) { + if (!passesChance(PlayerDispatcher(player))) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt index 3e2f56c05..ff6856d28 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.Tag import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -17,17 +18,17 @@ object EffectFeatherStep : Effect("feather_step") { private val players = listMap() override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - players[player.uniqueId] += identifiers.uuid + players[dispatcher.uuid] += identifiers.uuid } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - players[player.uniqueId] -= identifiers.uuid + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + players[dispatcher.uuid] -= identifiers.uuid } @EventHandler(ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt index d738b305a..5280e9954 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt @@ -6,6 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import java.util.UUID @@ -14,12 +16,22 @@ object EffectFlight : Effect("flight") { private val players = listMap() - override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData) { + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { + val player = dispatcher.get() ?: return + players[player.uniqueId] += identifiers.uuid player.allowFlight = players[player.uniqueId].isNotEmpty() } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val player = dispatcher.get() ?: return + players[player.uniqueId] -= identifiers.uuid player.allowFlight = players[player.uniqueId].isNotEmpty() } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt index 3bcfeba2b..b22a4d41a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent @@ -17,6 +18,6 @@ object EffectFoodMultiplier : MultiplierEffect("food_multiplier") { return } - event.foodLevel = player.foodLevel + ceil(getMultiplier(player) * diff).toInt() + event.foodLevel = player.foodLevel + ceil(getMultiplier(PlayerDispatcher(player)) * diff).toInt() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt index bd5159d6e..f36d6d231 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt @@ -2,6 +2,8 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.NumberUtils import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.EntityDispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent @@ -10,22 +12,22 @@ import kotlin.math.ceil object EffectHungerMultiplier : MultiplierEffect("hunger_multiplier") { @EventHandler(ignoreCancelled = true) fun handle(event: FoodLevelChangeEvent) { - val player = event.entity as? Player ?: return + val entity = event.entity - val diff = event.foodLevel - player.foodLevel + val diff = event.foodLevel - entity.foodLevel if (diff >= 0) { return } - val multiplier = getMultiplier(player) + val multiplier = getMultiplier(EntityDispatcher(entity)) if (multiplier < 1) { if (NumberUtils.randFloat(0.0, 1.0) > multiplier) { event.isCancelled = true } } else { - event.foodLevel = player.foodLevel + ceil(diff * getMultiplier(player)).toInt() + event.foodLevel = entity.foodLevel + ceil(diff * getMultiplier(EntityDispatcher(entity))).toInt() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt index 56fab963c..02223ec46 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.PlayerDeathEvent @@ -14,12 +15,18 @@ import java.util.UUID object EffectKeepInventory : Effect("keep_inventory") { private val players = listMap() - override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData) { - players[player.uniqueId] += identifiers.uuid + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { + players[dispatcher.uuid] += identifiers.uuid } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - players[player.uniqueId] -= identifiers.uuid + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + players[dispatcher.uuid] -= identifiers.uuid } @EventHandler(ignoreCancelled = true) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackMultiplier.kt index 52f8a19eb..e22ea5ee0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackMultiplier.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectKnockbackMultiplier : AttributeEffect( @@ -16,6 +17,6 @@ object EffectKnockbackMultiplier : AttributeEffect( require("multiplier", "You must specify the knockback multiplier!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("multiplier", player) - 1 + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("multiplier", entity as? Player) - 1 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackResistanceMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackResistanceMultiplier.kt index 15a9a5d7e..383e969ae 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackResistanceMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKnockbackResistanceMultiplier.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectKnockbackResistanceMultiplier : AttributeEffect( @@ -16,6 +17,6 @@ object EffectKnockbackResistanceMultiplier : AttributeEffect( require("multiplier", "You must specify the knockback resistance multiplier!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("multiplier", player) - 1 + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("multiplier", entity as? Player) - 1 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectLuckMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectLuckMultiplier.kt index 832527d33..0ce662183 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectLuckMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectLuckMultiplier.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectLuckMultiplier : AttributeEffect( @@ -16,6 +17,6 @@ object EffectLuckMultiplier : AttributeEffect( require("multiplier", "You must specify the luck multiplier!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("multiplier", player) - 1 + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("multiplier", entity as? Player) - 1 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMovementSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMovementSpeedMultiplier.kt index 9d416a07c..f92d6640d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMovementSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMovementSpeedMultiplier.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.AttributeEffect import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player object EffectMovementSpeedMultiplier : AttributeEffect( @@ -16,6 +17,6 @@ object EffectMovementSpeedMultiplier : AttributeEffect( require("multiplier", "You must specify the movement speed multiplier!") } - override fun getValue(config: Config, player: Player) = - config.getDoubleFromExpression("multiplier", player) - 1 + override fun getValue(config: Config, entity: LivingEntity) = + config.getDoubleFromExpression("multiplier", entity as? Player) - 1 } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt index 32a8f1660..e442a5575 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerRespawnEvent @@ -63,12 +65,14 @@ object EffectPermanentPotionEffect : Effect("permanent_potion_eff } override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { + val player = dispatcher.get() ?: return + val effectType = PotionEffectType.getByName(config.getString("effect").uppercase()) ?: PotionEffectType.INCREASE_DAMAGE @@ -93,7 +97,9 @@ object EffectPermanentPotionEffect : Effect("permanent_potion_eff player.setMetadata(metaKey, plugin.metadataValueFactory.create(meta)) } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val player = dispatcher.get() ?: return + val meta = player.getMetadata(metaKey).firstOrNull()?.value() as? MutableMap> ?: mutableMapOf() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt index 8071a9b52..fda6f119c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.duration import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -25,7 +26,9 @@ object EffectPotionDurationMultiplier : MultiplierEffect("potion_duration_multip fun handle(event: BrewEvent) { val player = event.contents.viewers.filterIsInstance().firstOrNull() ?: return - val multiplier = getMultiplier(player) + val multiplier = getMultiplier( + PlayerDispatcher(player) + ) plugin.scheduler.run { for (i in 0..2) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt index e958625fe..41c04b82f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt @@ -8,7 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import org.bukkit.entity.Player +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityShootBowEvent @@ -23,19 +24,19 @@ object EffectRapidBows : Effect("rapid_bows") { private val modifiers = listMap() override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - modifiers[player.uniqueId] += IdentifiedModifier(identifiers.uuid) { - config.getDoubleFromExpression("percent_faster", player) + modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) { + config.getDoubleFromExpression("percent_faster", dispatcher.get()) } } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - modifiers[player.uniqueId].removeIf { it.uuid == identifiers.uuid } + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + modifiers[dispatcher.uuid].removeIf { it.uuid == identifiers.uuid } } @EventHandler( @@ -43,9 +44,9 @@ object EffectRapidBows : Effect("rapid_bows") { ignoreCancelled = true ) fun handle(event: EntityShootBowEvent) { - val player = event.entity as? Player ?: return + val entity = event.entity - val totalPercentFaster = modifiers[player.uniqueId] + val totalPercentFaster = modifiers[entity.uniqueId] .sumOf { it.modifier } .coerceAtMost(100.0) diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt index cab528a96..9d3c5b948 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerFishEvent @@ -18,7 +19,7 @@ object EffectReelSpeedMultiplier : MultiplierEffect("reel_speed_multiplier") { val player = event.player - val multiplier = getMultiplier(player) + val multiplier = getMultiplier(PlayerDispatcher(player)) if (multiplier == 1.0) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt index 96b140922..971c48702 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiMultiplierEffect import com.willfp.libreforge.enumValueOfOrNull +import com.willfp.libreforge.triggers.EntityDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.EntityRegainHealthEvent @@ -18,12 +19,6 @@ object EffectRegenMultiplier : MultiMultiplierEffect("regen_multip @EventHandler(ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - val player = event.entity - - if (player !is Player) { - return - } - - event.amount *= getMultiplier(player, event.regainReason) + event.amount *= getMultiplier(EntityDispatcher(event.entity), event.regainReason) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt index f27a4725a..79f7fe23a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt @@ -9,6 +9,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.block.BlockFace @@ -30,21 +31,21 @@ object EffectReplantCrops : Effect("replant_crops") { private val players = listMap() override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - players[player.uniqueId] += ReplantConfig( + players[dispatcher.uuid] += ReplantConfig( identifiers.uuid, config.getBool("consume_seeds"), config.getBool("only_fully_grown") ) } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - players[player.uniqueId].removeIf { it.uuid == identifiers.uuid } + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + players[dispatcher.uuid].removeIf { it.uuid == identifiers.uuid } } @EventHandler( diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt index 8a60bf39b..f94d6234f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler object EffectSellMultiplier : MultiplierEffect("sell_multiplier") { @EventHandler fun handle(event: ShopSellEvent) { - event.multiplier *= getMultiplier(event.player) + event.multiplier *= getMultiplier(PlayerDispatcher(event.player)) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt index 2cec67be1..e69171a65 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt @@ -12,6 +12,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher import org.bukkit.GameMode import org.bukkit.Material import org.bukkit.Tag @@ -28,17 +29,17 @@ object EffectTelekinesis : Effect("telekinesis") { private val players = listMap() override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - players[player.uniqueId] += identifiers.uuid + players[dispatcher.uuid] += identifiers.uuid } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - players[player.uniqueId] -= identifiers.uuid + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + players[dispatcher.uuid] -= identifiers.uuid } override fun postRegister() { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt index b82bd5254..32f523a02 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.events.NaturalExpGainEvent import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler import kotlin.math.ceil @@ -10,7 +11,7 @@ object EffectXpMultiplier : MultiplierEffect("xp_multiplier") { fun handle(event: NaturalExpGainEvent) { val player = event.expChangeEvent.player - val multiplier = getMultiplier(player) + val multiplier = getMultiplier(PlayerDispatcher(player)) event.expChangeEvent.amount = ceil(event.expChangeEvent.amount * multiplier).toInt() } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt index d531ba0d1..b9415552c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt @@ -6,9 +6,12 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeInstance import org.bukkit.attribute.AttributeModifier +import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player abstract class AttributeEffect( @@ -16,7 +19,7 @@ abstract class AttributeEffect( private val attribute: Attribute, private val operation: AttributeModifier.Operation ) : Effect(id) { - protected abstract fun getValue(config: Config, player: Player): Double + protected abstract fun getValue(config: Config, entity: LivingEntity): Double private fun AttributeInstance.clean(name: String) { for (modifier in this.modifiers.toList()) { @@ -26,18 +29,19 @@ abstract class AttributeEffect( } } - open fun constrainAttribute(player: Player, value: Double) { + open fun constrainAttribute(entity: LivingEntity, value: Double) { // Override this to constrain the attribute value, e.g. to set health below max health. } - final override fun onEnable( - player: Player, + override fun onEnable( + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - val instance = player.getAttribute(attribute) ?: return + val entity = dispatcher.get() ?: return + val instance = entity.getAttribute(attribute) ?: return val modifierName = "libreforge:${this.id} - ${identifiers.key.key} (${holder.holder.id})" instance.clean(modifierName) @@ -46,29 +50,22 @@ abstract class AttributeEffect( AttributeModifier( identifiers.uuid, modifierName, - getValue(config, player), + getValue(config, entity), operation ) ) } - final override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - val instance = player.getAttribute(attribute) ?: return + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val entity = dispatcher.get() ?: return + val instance = entity.getAttribute(attribute) ?: return val modifierName = "libreforge:${this.id} - ${identifiers.key.key} (${holder.holder.id})" - instance.clean(modifierName) - instance.removeModifier( - AttributeModifier( - identifiers.uuid, - modifierName, - 0.0, - operation - ) - ) + instance.clean(modifierName) // Run on next tick to prevent constraining to the lower value during reloads. plugin.scheduler.run { - constrainAttribute(player, instance.value) + constrainAttribute(entity, instance.value) } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt index cf2c38949..b416541bd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt @@ -9,6 +9,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import java.util.UUID @@ -19,29 +22,37 @@ abstract class ChanceMultiplierEffect(id: String) : Effect(id) { private val modifiers = listMap() - final override fun onEnable( - player: Player, + override fun onEnable( + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { - modifiers[player.uniqueId] += IdentifiedModifier(identifiers.uuid) { - config.getDoubleFromExpression("chance", player) + modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) { + config.getDoubleFromExpression("chance", dispatcher.get()!!) } } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - modifiers[player.uniqueId].removeIf { it.uuid == identifiers.uuid } + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + modifiers[dispatcher.uuid].removeIf { it.uuid == identifiers.uuid } } - protected fun passesChance(player: Player): Boolean { + protected fun passesChance(dispatcher: Dispatcher<*>): Boolean { var chance = 1.0 - for (modifier in modifiers[player.uniqueId]) { + for (modifier in modifiers[dispatcher.uuid]) { chance *= (100 - modifier.modifier) / 100 } return randDouble(0.0, 1.0) > chance } + + @Deprecated( + "Use passesChance(dispatcher: Dispatcher<*>) instead.", + ReplaceWith("passesChance(dispatcher)"), + DeprecationLevel.ERROR + ) + protected fun passesChance(player: Player): Boolean = + passesChance(PlayerDispatcher(player)) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt index 97f19ef88..70aaa5805 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt @@ -9,6 +9,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import java.util.UUID @@ -25,44 +28,58 @@ abstract class MultiMultiplierEffect(id: String) : Effect, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { if (config.has(key)) { val elements = config.getStrings(key).mapNotNull { getElement(it) } for (element in elements) { - modifiers[player.uniqueId][element] += IdentifiedModifier(identifiers.uuid) { - config.getDoubleFromExpression("multiplier", player) + modifiers[dispatcher.uuid][element] += IdentifiedModifier(identifiers.uuid) { + config.getDoubleFromExpression("multiplier", dispatcher.get()) } } } else { - globalModifiers[player.uniqueId] += IdentifiedModifier(identifiers.uuid) { - config.getDoubleFromExpression("multiplier", player) + globalModifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) { + config.getDoubleFromExpression("multiplier", dispatcher.get()) } } } - final override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - globalModifiers[player.uniqueId].removeIf { it.uuid == identifiers.uuid } + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + globalModifiers[dispatcher.uuid].removeIf { it.uuid == identifiers.uuid } for (element in getAllElements()) { - modifiers[player.uniqueId][element].removeIf { it.uuid == identifiers.uuid } + modifiers[dispatcher.uuid][element].removeIf { it.uuid == identifiers.uuid } } } - protected fun getMultiplier(player: Player, element: T): Double { + protected fun getMultiplier(dispatcher: Dispatcher<*>, element: T): Double { var multiplier = 1.0 - for (modifier in globalModifiers[player.uniqueId]) { + for (modifier in globalModifiers[dispatcher.uuid]) { multiplier *= modifier.modifier } - for (modifier in modifiers[player.uniqueId][element]) { + for (modifier in modifiers[dispatcher.uuid][element]) { multiplier *= modifier.modifier } return multiplier } + @Deprecated( + "Use getMultiplier(dispatcher: Dispatcher<*>, element: T) instead.", + ReplaceWith("getMultiplier(dispatcher, element)"), + DeprecationLevel.ERROR + ) + protected fun getMultiplier(player: Player, element: T): Double = + getMultiplier(PlayerDispatcher(player), element) + /** * Get an element by [key], for example a stat. */ diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt index e9a097225..52b624b7a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt @@ -8,6 +8,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player import java.util.UUID @@ -18,23 +21,37 @@ abstract class MultiplierEffect(id: String) : Effect(id) { private val modifiers = listMap() - final override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData) { - modifiers[player.uniqueId] += IdentifiedModifier(identifiers.uuid) { - config.getDoubleFromExpression("multiplier", player) + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { + modifiers[dispatcher.uuid] += IdentifiedModifier(identifiers.uuid) { + config.getDoubleFromExpression("multiplier", dispatcher.get()!!) } } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - modifiers[player.uniqueId].removeIf { it.uuid == identifiers.uuid } + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + modifiers[dispatcher.uuid].removeIf { it.uuid == identifiers.uuid } } - protected fun getMultiplier(player: Player): Double { + protected fun getMultiplier(dispatcher: Dispatcher<*>): Double { var multiplier = 1.0 - for (modifier in modifiers[player.uniqueId]) { + for (modifier in modifiers[dispatcher.uuid]) { multiplier *= modifier.modifier } return multiplier } + + @Deprecated( + "Use getMultiplier(dispatcher: Dispatcher<*>) instead.", + ReplaceWith("getMultiplier(dispatcher)"), + DeprecationLevel.ERROR + ) + protected fun getMultiplier(player: Player): Double = + getMultiplier(PlayerDispatcher(player)) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt index 7ed575b20..3c9402ab6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt @@ -9,6 +9,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import org.bukkit.entity.Player object EffectAddStat : Effect("add_stat") { @@ -18,12 +20,14 @@ object EffectAddStat : Effect("add_stat") { } override fun onEnable( - player: Player, + dispatcher: Dispatcher<*>, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData ) { + val player = dispatcher.get() ?: return + AureliumAPI.addStatModifier( player, identifiers.key.key, @@ -32,7 +36,9 @@ object EffectAddStat : Effect("add_stat") { ) } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val player = dispatcher.get() ?: return + AureliumAPI.getPlugin().playerManager.getPlayerData(player) ?.removeStatModifier(identifiers.key.key, false) diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt index a289928ad..61ef14d91 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt @@ -4,6 +4,7 @@ import com.archyx.aureliumskills.api.event.XpGainEvent import com.archyx.aureliumskills.skills.Skill import com.archyx.aureliumskills.skills.Skills import com.willfp.libreforge.effects.templates.MultiMultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multiplier") { @@ -21,7 +22,7 @@ object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multipli fun handle(event: XpGainEvent) { val player = event.player - val multiplier = getMultiplier(player, event.skill) + val multiplier = getMultiplier(PlayerDispatcher(player), event.skill) event.amount *= multiplier } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt index 0c1e2bf03..8093059cd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsPaymentEvent import com.gamingmesh.jobs.container.CurrencyType import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -11,7 +12,7 @@ object EffectJobsMoneyMultiplier : MultiplierEffect("jobs_money_multiplier") { fun handle(event: JobsPaymentEvent) { val player = event.player as? Player ?: return - val multiplier = getMultiplier(player) + val multiplier = getMultiplier(PlayerDispatcher(player)) var money = event.payment[CurrencyType.MONEY] ?: return money *= multiplier diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt index 0b15a1239..de23c0dc4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt @@ -4,6 +4,7 @@ import com.gamingmesh.jobs.Jobs import com.gamingmesh.jobs.api.JobsExpGainEvent import com.gamingmesh.jobs.container.Job import com.willfp.libreforge.effects.templates.MultiMultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -22,6 +23,6 @@ object EffectJobsXpMultiplier : MultiMultiplierEffect("jobs_xp_multiplier") fun handle(event: JobsExpGainEvent) { val player = event.player as? Player ?: return - event.exp *= getMultiplier(player, event.job) + event.exp *= getMultiplier(PlayerDispatcher(player), event.job) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt index e1a3c5018..3984655b9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt @@ -4,6 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent import com.gmail.nossr50.mcMMO import com.willfp.libreforge.effects.templates.MultiMultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_xp_multiplier") { @@ -21,6 +22,6 @@ object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_ fun handle(event: McMMOPlayerXpGainEvent) { val player = event.player - event.rawXpGained *= getMultiplier(player, event.skill).toFloat() + event.rawXpGained *= getMultiplier(PlayerDispatcher(player), event.skill).toFloat() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt index d138eefcb..75f29163a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.event.EventHandler object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_chance") { @@ -9,7 +10,7 @@ object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_c fun handle(event: PlayerElytraBoostEvent) { val player = event.player - if (passesChance(player)) { + if (passesChance(PlayerDispatcher(player))) { event.setShouldConsume(false) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt index cb612fc9e..14540edc6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt @@ -5,11 +5,11 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.integrations.LoadableIntegration import com.willfp.libreforge.integrations.jobs.impl.EffectJobsMoneyMultiplier import com.willfp.libreforge.integrations.jobs.impl.EffectJobsXpMultiplier +import com.willfp.libreforge.integrations.tmmobcoins.impl.EffectMobCoinsMultiplier object TMMobcoinsIntegration : LoadableIntegration { override fun load(plugin: EcoPlugin) { - Effects.register(EffectJobsXpMultiplier) - Effects.register(EffectJobsMoneyMultiplier) + Effects.register(EffectMobCoinsMultiplier) } override fun getPluginName(): String { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt index 4e31cc5cb..f741ba6c7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.integrations.tmmobcoins.impl import com.willfp.libreforge.effects.templates.MultiplierEffect +import com.willfp.libreforge.triggers.PlayerDispatcher import net.devtm.tmmobcoins.API.MobCoinReceiveEvent import org.bukkit.event.EventHandler @@ -9,6 +10,6 @@ object EffectMobCoinsMultiplier : MultiplierEffect("mob_coins_multiplier") { fun handle(event: MobCoinReceiveEvent) { val player = event.player - event.setDropAmount(event.obtainedAmount * getMultiplier(player)) + event.setDropAmount(event.obtainedAmount * getMultiplier(PlayerDispatcher(player))) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt index 7117e0606..dc647674b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt @@ -8,6 +8,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers +import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.triggers.get import net.milkbowl.vault.permission.Permission import org.bukkit.entity.Player import java.util.UUID @@ -21,21 +23,31 @@ class EffectGivePermission( private val permissions = listMap() - override fun onEnable(player: Player, config: Config, identifiers: Identifiers, holder: ProvidedHolder, compileData: NoCompileData) { + override fun onEnable( + dispatcher: Dispatcher<*>, + config: Config, + identifiers: Identifiers, + holder: ProvidedHolder, + compileData: NoCompileData + ) { + val player = dispatcher.get() ?: return + val permission = config.getString("permission") - permissions[player.uniqueId] += GivenPermission(permission, identifiers.uuid) + permissions[dispatcher.uuid] += GivenPermission(permission, identifiers.uuid) handler.playerAdd(player, permission) } - override fun onDisable(player: Player, identifiers: Identifiers, holder: ProvidedHolder) { - val permission = permissions[player.uniqueId] + override fun onDisable(dispatcher: Dispatcher<*>, identifiers: Identifiers, holder: ProvidedHolder) { + val player = dispatcher.get() ?: return + + val permission = permissions[dispatcher.uuid] .firstOrNull { it.uuid == identifiers.uuid } ?: return - permissions[player.uniqueId].remove(permission) + permissions[dispatcher.uuid].remove(permission) // Remove the permission only if no other effect is giving it - if (permissions[player.uniqueId].none { it.permission == permission.permission }) { + if (permissions[dispatcher.uuid].none { it.permission == permission.permission }) { handler.playerRemove(player, permission.permission) } } From f76e59f91bf86a0e022a0f066173ff64fc29731a Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 14:47:19 +0000 Subject: [PATCH 04/11] Moved Dispatcher --- .../com/willfp/libreforge/{triggers => }/Dispatcher.kt | 3 +-- .../kotlin/com/willfp/libreforge/EffectCollisionFixer.kt | 1 - core/src/main/kotlin/com/willfp/libreforge/Holder.kt | 2 -- .../main/kotlin/com/willfp/libreforge/HolderProvider.kt | 1 - .../kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt | 2 -- .../kotlin/com/willfp/libreforge/conditions/Condition.kt | 3 +-- .../com/willfp/libreforge/conditions/ConditionBlock.kt | 8 +++----- .../com/willfp/libreforge/conditions/ConditionList.kt | 9 +++------ .../libreforge/conditions/impl/ConditionAboveBalance.kt | 4 ++-- .../conditions/impl/ConditionAboveGlobalPoints.kt | 4 ++-- .../conditions/impl/ConditionAboveHealthPercent.kt | 4 ++-- .../conditions/impl/ConditionAboveHungerPercent.kt | 4 ++-- .../libreforge/conditions/impl/ConditionAbovePoints.kt | 4 ++-- .../libreforge/conditions/impl/ConditionAboveXPLevel.kt | 4 ++-- .../willfp/libreforge/conditions/impl/ConditionAboveY.kt | 8 ++------ .../willfp/libreforge/conditions/impl/ConditionAnyOf.kt | 3 +-- .../libreforge/conditions/impl/ConditionAtLeastOf.kt | 4 ++-- .../libreforge/conditions/impl/ConditionBelowBalance.kt | 4 ++-- .../conditions/impl/ConditionBelowGlobalPoints.kt | 4 ++-- .../conditions/impl/ConditionBelowHealthPercent.kt | 4 ++-- .../conditions/impl/ConditionBelowHungerPercent.kt | 4 ++-- .../libreforge/conditions/impl/ConditionBelowPoints.kt | 4 ++-- .../libreforge/conditions/impl/ConditionBelowXPLevel.kt | 4 ++-- .../willfp/libreforge/conditions/impl/ConditionBelowY.kt | 6 ++---- .../conditions/impl/ConditionCanAffordPrice.kt | 4 ++-- .../conditions/impl/ConditionGlobalPointsEqual.kt | 4 ++-- .../libreforge/conditions/impl/ConditionHasItemData.kt | 4 +--- .../libreforge/conditions/impl/ConditionHasPermission.kt | 4 ++-- .../conditions/impl/ConditionHasPotionEffect.kt | 5 ++--- .../willfp/libreforge/conditions/impl/ConditionInAir.kt | 5 +---- .../libreforge/conditions/impl/ConditionInBiome.kt | 5 +---- .../libreforge/conditions/impl/ConditionInBlock.kt | 6 ++---- .../libreforge/conditions/impl/ConditionInWater.kt | 5 ++--- .../libreforge/conditions/impl/ConditionInWorld.kt | 5 +---- .../conditions/impl/ConditionIsExpressionTrue.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsFalling.kt | 5 ++--- .../libreforge/conditions/impl/ConditionIsFlying.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsFrozen.kt | 5 ++--- .../libreforge/conditions/impl/ConditionIsGliding.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsNight.kt | 5 +---- .../willfp/libreforge/conditions/impl/ConditionIsOp.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsSneaking.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsSprinting.kt | 4 ++-- .../libreforge/conditions/impl/ConditionIsStorm.kt | 5 +---- .../libreforge/conditions/impl/ConditionIsSwimming.kt | 4 ++-- .../conditions/impl/ConditionItemDataEquals.kt | 6 ++---- .../conditions/impl/ConditionItemLevelAbove.kt | 6 ++---- .../conditions/impl/ConditionItemLevelBelow.kt | 4 ++-- .../conditions/impl/ConditionItemLevelEquals.kt | 4 ++-- .../conditions/impl/ConditionItemPointsAbove.kt | 4 ++-- .../conditions/impl/ConditionItemPointsBelow.kt | 4 ++-- .../conditions/impl/ConditionItemPointsEqual.kt | 4 ++-- .../libreforge/conditions/impl/ConditionNearEntity.kt | 6 ++---- .../willfp/libreforge/conditions/impl/ConditionOnFire.kt | 4 ++-- .../libreforge/conditions/impl/ConditionOnGround.kt | 6 +----- .../conditions/impl/ConditionPlaceholderContains.kt | 5 ++--- .../conditions/impl/ConditionPlaceholderEquals.kt | 4 ++-- .../conditions/impl/ConditionPlaceholderGreaterThan.kt | 4 ++-- .../conditions/impl/ConditionPlaceholderLessThan.kt | 4 ++-- .../libreforge/conditions/impl/ConditionPointsEqual.kt | 4 ++-- .../libreforge/conditions/impl/ConditionRidingEntity.kt | 4 ++-- .../conditions/impl/ConditionStandingOnBlock.kt | 4 ++-- .../conditions/impl/ConditionWithinRadiusOf.kt | 6 ++---- .../libreforge/conditions/templates/ItemCondition.kt | 4 ++-- .../com/willfp/libreforge/counters/bind/BoundCounter.kt | 2 +- .../main/kotlin/com/willfp/libreforge/effects/Chain.kt | 6 +++--- .../kotlin/com/willfp/libreforge/effects/ChainElement.kt | 4 ++-- .../main/kotlin/com/willfp/libreforge/effects/Effect.kt | 7 +++---- .../kotlin/com/willfp/libreforge/effects/EffectBlock.kt | 5 ++--- .../effects/arguments/impl/ArgumentChainArgs.kt | 2 +- .../effects/arguments/impl/ArgumentCooldown.kt | 3 +-- .../libreforge/effects/arguments/impl/ArgumentCost.kt | 2 +- .../effects/arguments/impl/ArgumentPointCost.kt | 2 +- .../libreforge/effects/arguments/impl/ArgumentPrice.kt | 2 +- .../libreforge/effects/events/EffectDisableEvent.kt | 5 ++--- .../libreforge/effects/events/EffectEnableEvent.kt | 5 ++--- .../com/willfp/libreforge/effects/impl/EffectAOE.kt | 5 +---- .../willfp/libreforge/effects/impl/EffectAOEBlocks.kt | 2 +- .../effects/impl/EffectAddPermanentHolderInRadius.kt | 4 ++-- .../willfp/libreforge/effects/impl/EffectAddPoints.kt | 4 ++-- .../willfp/libreforge/effects/impl/EffectAllPlayers.kt | 2 +- .../libreforge/effects/impl/EffectBlockCommands.kt | 3 +-- .../libreforge/effects/impl/EffectBrewTimeMultiplier.kt | 2 +- .../effects/impl/EffectDontConsumeLapisChance.kt | 2 +- .../libreforge/effects/impl/EffectDontConsumeXpChance.kt | 2 +- .../willfp/libreforge/effects/impl/EffectFeatherStep.kt | 3 +-- .../com/willfp/libreforge/effects/impl/EffectFlight.kt | 4 ++-- .../libreforge/effects/impl/EffectFoodMultiplier.kt | 2 +- .../libreforge/effects/impl/EffectHungerMultiplier.kt | 4 +--- .../libreforge/effects/impl/EffectKeepInventory.kt | 3 +-- .../effects/impl/EffectPermanentPotionEffect.kt | 4 ++-- .../effects/impl/EffectPotionDurationMultiplier.kt | 2 +- .../willfp/libreforge/effects/impl/EffectRandomPlayer.kt | 2 +- .../willfp/libreforge/effects/impl/EffectRapidBows.kt | 4 ++-- .../libreforge/effects/impl/EffectReelSpeedMultiplier.kt | 2 +- .../libreforge/effects/impl/EffectRegenMultiplier.kt | 3 +-- .../willfp/libreforge/effects/impl/EffectReplantCrops.kt | 3 +-- .../com/willfp/libreforge/effects/impl/EffectRunChain.kt | 2 +- .../libreforge/effects/impl/EffectRunChainInline.kt | 2 +- .../libreforge/effects/impl/EffectSellMultiplier.kt | 2 +- .../willfp/libreforge/effects/impl/EffectTelekinesis.kt | 5 +---- .../libreforge/effects/impl/EffectTriggerNestedChain.kt | 5 +---- .../willfp/libreforge/effects/impl/EffectXpMultiplier.kt | 2 +- .../libreforge/effects/templates/AttributeEffect.kt | 5 ++--- .../effects/templates/ChanceMultiplierEffect.kt | 6 +++--- .../effects/templates/MultiMultiplierEffect.kt | 6 +++--- .../libreforge/effects/templates/MultiplierEffect.kt | 6 +++--- .../libreforge/filters/impl/FilterVictimConditions.kt | 4 +--- .../integrations/aureliumskills/impl/ArgumentManaCost.kt | 2 +- .../integrations/aureliumskills/impl/ConditionHasMana.kt | 4 ++-- .../integrations/aureliumskills/impl/EffectAddStat.kt | 4 ++-- .../aureliumskills/impl/EffectSkillXpMultiplier.kt | 2 +- .../integrations/citizens/impl/TriggerLeftClickNPC.kt | 2 +- .../integrations/citizens/impl/TriggerRightClickNPC.kt | 3 +-- .../integrations/jobs/impl/EffectJobsMoneyMultiplier.kt | 2 +- .../integrations/jobs/impl/EffectJobsXpMultiplier.kt | 2 +- .../integrations/jobs/impl/TriggerJobsLevelUp.kt | 2 +- .../integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt | 2 +- .../integrations/paper/impl/ConditionInBubble.kt | 5 ++--- .../integrations/paper/impl/ConditionInLava.kt | 5 ++--- .../integrations/paper/impl/ConditionInRain.kt | 5 ++--- .../integrations/paper/impl/EffectDropPickupItem.kt | 2 +- .../paper/impl/EffectElytraBoostSaveChance.kt | 2 +- .../integrations/paper/impl/TriggerBeaconEffect.kt | 2 +- .../integrations/paper/impl/TriggerElytraBoost.kt | 2 +- .../libreforge/integrations/paper/impl/TriggerSwing.kt | 2 +- .../integrations/paper/impl/TriggerVillagerTrade.kt | 2 +- .../scyther/impl/TriggerScytherAutoCollect.kt | 2 +- .../integrations/scyther/impl/TriggerScytherAutoSell.kt | 2 +- .../tmmobcoins/impl/EffectMobCoinsMultiplier.kt | 2 +- .../integrations/vault/impl/EffectGivePermission.kt | 5 ++--- .../integrations/worldguard/impl/ConditionInRegion.kt | 4 +--- .../integrations/worldguard/impl/TriggerEnterRegion.kt | 2 +- .../integrations/worldguard/impl/TriggerLeaveRegion.kt | 2 +- .../kotlin/com/willfp/libreforge/levels/LevelType.kt | 2 +- .../placeholders/impl/ConditionalCustomPlaceholder.kt | 2 +- .../com/willfp/libreforge/triggers/DispatchedTrigger.kt | 3 +++ .../libreforge/triggers/DispatchedTriggerFactory.kt | 2 ++ .../kotlin/com/willfp/libreforge/triggers/Trigger.kt | 5 +++++ .../kotlin/com/willfp/libreforge/triggers/TriggerData.kt | 2 ++ .../libreforge/triggers/event/TriggerDispatchEvent.kt | 5 ++--- .../willfp/libreforge/triggers/impl/TriggerAltClick.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerBite.kt | 2 +- .../libreforge/triggers/impl/TriggerBlockItemDrop.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerBowAttack.kt | 3 +-- .../com/willfp/libreforge/triggers/impl/TriggerBreed.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerBrew.kt | 2 +- .../libreforge/triggers/impl/TriggerBrewIngredient.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerCastRod.kt | 2 +- .../libreforge/triggers/impl/TriggerCatchEntity.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerCatchFish.kt | 2 +- .../libreforge/triggers/impl/TriggerCatchFishFail.kt | 2 +- .../libreforge/triggers/impl/TriggerChangeArmor.kt | 2 +- .../libreforge/triggers/impl/TriggerChangeChunk.kt | 2 +- .../libreforge/triggers/impl/TriggerChangeWorld.kt | 3 +-- .../willfp/libreforge/triggers/impl/TriggerClickBlock.kt | 3 +-- .../libreforge/triggers/impl/TriggerClickEntity.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerConsume.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerCraft.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerDamageItem.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerDeath.kt | 2 +- .../libreforge/triggers/impl/TriggerDeployElytra.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerDisable.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerDrink.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerDropItem.kt | 2 +- .../libreforge/triggers/impl/TriggerEmptyBucket.kt | 3 +-- .../com/willfp/libreforge/triggers/impl/TriggerEnable.kt | 2 +- .../libreforge/triggers/impl/TriggerEnchantItem.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerEnterBed.kt | 2 +- .../libreforge/triggers/impl/TriggerEntityItemDrop.kt | 2 +- .../libreforge/triggers/impl/TriggerEntityTarget.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerFallDamage.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerFillBucket.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerGainHunger.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerGainXp.kt | 2 +- .../libreforge/triggers/impl/TriggerGroupCustom.kt | 2 +- .../libreforge/triggers/impl/TriggerGroupStatic.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerHeadshot.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerHeal.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerHoldItem.kt | 2 +- .../libreforge/triggers/impl/TriggerHookInGround.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerItemBreak.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerJoin.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerJump.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerKill.kt | 2 +- .../libreforge/triggers/impl/TriggerLeashEntity.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerLeave.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerLeaveBed.kt | 2 +- .../libreforge/triggers/impl/TriggerLevelUpItem.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerLoseHunger.kt | 2 +- .../libreforge/triggers/impl/TriggerLosePotionEffect.kt | 2 +- .../libreforge/triggers/impl/TriggerMeleeAttack.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerMineBlock.kt | 2 +- .../libreforge/triggers/impl/TriggerMineBlockProgress.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerMove.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerPickUpItem.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt | 2 +- .../libreforge/triggers/impl/TriggerPotionEffect.kt | 2 +- .../libreforge/triggers/impl/TriggerProjectileHit.kt | 2 +- .../libreforge/triggers/impl/TriggerProjectileLaunch.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerReelIn.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerRespawn.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerRunCommand.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerSellItem.kt | 2 +- .../libreforge/triggers/impl/TriggerSendMessage.kt | 2 +- .../libreforge/triggers/impl/TriggerShearEntity.kt | 2 +- .../libreforge/triggers/impl/TriggerShieldBlock.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerShootBow.kt | 2 +- .../com/willfp/libreforge/triggers/impl/TriggerSmelt.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerSwapHands.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerTakeDamage.kt | 2 +- .../libreforge/triggers/impl/TriggerTakeEntityDamage.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerTameAnimal.kt | 3 +-- .../willfp/libreforge/triggers/impl/TriggerTeleport.kt | 2 +- .../libreforge/triggers/impl/TriggerToggleFlight.kt | 2 +- .../libreforge/triggers/impl/TriggerToggleSneak.kt | 2 +- .../libreforge/triggers/impl/TriggerToggleSprint.kt | 2 +- .../libreforge/triggers/impl/TriggerTridentAttack.kt | 2 +- .../willfp/libreforge/triggers/impl/TriggerWinRaid.kt | 2 +- 220 files changed, 303 insertions(+), 384 deletions(-) rename core/src/main/kotlin/com/willfp/libreforge/{triggers => }/Dispatcher.kt (96%) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt similarity index 96% rename from core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt rename to core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt index 80151ee08..2f229bbf6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt @@ -1,9 +1,8 @@ -package com.willfp.libreforge.triggers +package com.willfp.libreforge import org.bukkit.Location import org.bukkit.entity.Entity import org.bukkit.entity.Player -import java.util.Locale import java.util.UUID /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt index 7c4110649..150969c0a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge import com.willfp.libreforge.effects.Effects -import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.attribute.Attribute import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt index 343f98908..33db78d4c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt @@ -3,8 +3,6 @@ package com.willfp.libreforge import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.EffectList -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.NamespacedKey import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 9caa0c3f5..9d1c4d0b7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.map.listMap import com.willfp.libreforge.effects.EffectBlock -import com.willfp.libreforge.triggers.PlayerDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import org.bukkit.event.HandlerList diff --git a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt index f9ecfc15b..3f7d5eae7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt @@ -5,8 +5,6 @@ import com.willfp.eco.core.placeholder.context.PlaceholderContext import com.willfp.eco.core.placeholder.context.copy import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.formatEco -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.ifType import org.bukkit.entity.Player /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt index 84fcf665a..ae5ecc534 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt @@ -4,8 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.Compilable import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.Dispatcher import org.bukkit.entity.Player import org.bukkit.event.Listener diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt index 3e497935a..0ee906d85 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt @@ -3,15 +3,13 @@ package com.willfp.libreforge.conditions import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.interfaces.Config 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 com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt index b85e9bee7..c1940f205 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt @@ -2,14 +2,11 @@ package com.willfp.libreforge.conditions import com.willfp.eco.util.formatEco import com.willfp.libreforge.DelegatedList -import com.willfp.libreforge.EmptyProvidedHolder -import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.GlobalDispatcher.dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt index 7b9e7b019..e2576d65e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionAboveBalance : Condition("above_balance") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt index 9674d618d..4ca7cc150 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionAboveGlobalPoints : Condition("above_global_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt index 3cc7b9504..e601a8468 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute import org.bukkit.entity.LivingEntity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt index 7ec945f4b..05f8efa4e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt index d7cf167c7..60b0eea2d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionAbovePoints : Condition("above_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt index 72f18994a..8529b5301 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt index bb8bd08f9..92a15479a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt @@ -5,12 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import com.willfp.libreforge.triggers.ifType -import org.bukkit.block.Block -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get object ConditionAboveY : Condition("above_y") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt index 25328d2ad..f7a0dbab3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt @@ -7,8 +7,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions -import com.willfp.libreforge.triggers.Dispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionAnyOf : Condition("any_of") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt index 2efb5e1cb..ee867cc00 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionAtLeastOf : Condition("at_least_of") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt index a6573d59e..9c88cee8f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionBelowBalance : Condition("below_balance") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt index d04df983e..ecc703a58 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionBelowGlobalPoints : Condition("below_global_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt index 3074d9890..6f247c44a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute import org.bukkit.entity.LivingEntity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt index 265403cb9..8e001dfb1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt index 1c0ab8f41..986a80c33 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionBelowPoints : Condition("below_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt index 147314323..5b1a96624 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt index 22a59c076..4d33ac0da 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt @@ -5,10 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get object ConditionBelowY : Condition("below_y") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt index a74759ec4..5ecaa7bbe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionCanAffordPrice : Condition("can_afford_price") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt index 4c4814e94..0571c0e5d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionGlobalPointsEqual : Condition("global_points_equal") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt index baf00f6b9..e0c50752c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt @@ -7,9 +7,7 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher import org.bukkit.inventory.ItemStack object ConditionHasItemData : Condition("has_item_data") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt index 4069f1a5c..e1685e98e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt index 7185f435e..8286ffba5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt @@ -6,10 +6,9 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player object ConditionHasPotionEffect : Condition("has_potion_effect") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt index 08049a69c..6b09885ff 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt @@ -4,10 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionInAir : Condition("in_air") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt index 2d8a4126f..0a9303f63 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt @@ -5,10 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionInBiome : Condition("in_biome") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt index c6bd4af84..95a8f52ac 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt @@ -5,11 +5,9 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player object ConditionInBlock : Condition("in_block") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt index 593355deb..ec1d63a83 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionInWater : Condition("in_water") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt index 9c50e66f6..bf825a2fd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt @@ -5,10 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionInWorld : Condition("in_world") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt index 11376b5d5..73f791bf9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionIsExpressionTrue : Condition("is_expression_true") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt index 490558e97..efd8fbe90 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionIsFalling : Condition("is_falling") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt index bf9c8ac0b..2fdb6f154 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionIsFlying : Condition("is_flying") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt index a2e05b6c1..40307099e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player object ConditionIsFrozen : Condition("is_frozen") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt index d3be28281..0d611cbb8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt index f8c92a75d..f4a2b72ab 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt @@ -4,10 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionIsNight : Condition("is_night") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt index 24c6ef8ab..ca3cfa881 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionIsOp : Condition("is_op") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt index c7694aa32..7f0b4351d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt index b0953e64a..1c64e1711 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt index 070ff6fc8..a6c084afd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt @@ -4,11 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.updateEffects -import org.bukkit.entity.Entity -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.weather.WeatherChangeEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt index fd1a60cff..7c1319194 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt index da3cb82f3..8e986a361 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt @@ -6,12 +6,10 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.getFormattedString import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData -import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt index 51ed0584b..b42bfa17c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt @@ -1,8 +1,6 @@ package com.willfp.libreforge.conditions.impl -import com.gamingmesh.jobs.commands.list.level import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments @@ -10,8 +8,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt index 9cbfdea35..721a15c45 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt index 83ea81a7e..28e8950b6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt index da1264308..e3079b1b8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt index cf94622b5..aa6973924 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt index b27754c41..64f555c41 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt index bffe334f0..2d05c587f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt @@ -8,10 +8,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get object ConditionNearEntity : Condition>("near_entity") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt index eec2dc2b4..9564f9192 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt index a7f27e359..6aa1e70ff 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt @@ -4,12 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.getProvider -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher import org.bukkit.block.BlockFace -import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionOnGround : Condition("on_ground") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt index bf68b82a5..32f254a7e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt @@ -6,9 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.getProvider -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionPlaceholderContains : Condition("placeholder_contains") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt index 0d755df52..4a4d19605 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt index 5d71c9cf0..55b940b36 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt index 4365825bc..daa1d285f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt index 33906b692..27cce20bf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionPointsEqual : Condition("points_equal") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt index 05fe07be3..1ccd57c51 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt index f311d13a0..e1db57a28 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object ConditionStandingOnBlock : Condition("standing_on_block") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt index d38df1f11..5328261aa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt @@ -5,10 +5,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get -import org.bukkit.entity.Entity -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.util.Vector import kotlin.math.pow diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt index cdb6adfe6..766a8d0ae 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt @@ -10,8 +10,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.filterNotEmpty import com.willfp.libreforge.getStrings -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt index 168d21be0..94fd92d43 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt @@ -5,7 +5,7 @@ import com.willfp.eco.util.evaluateExpression import com.willfp.libreforge.counters.Accumulator import com.willfp.libreforge.counters.Counter import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import org.bukkit.entity.Player /* diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt index 75a2cc2b7..dee5b534f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt @@ -4,11 +4,11 @@ import com.willfp.libreforge.DelegatedList import com.willfp.libreforge.WeightedList import com.willfp.libreforge.effects.executors.ChainExecutor import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import com.willfp.libreforge.triggers.impl.TriggerBlank import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt index 0cdfb41f3..c7dedccc7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt @@ -11,8 +11,8 @@ import com.willfp.libreforge.effects.events.EffectEnableEvent import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt index 1ff7dd3f0..d403726ca 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt @@ -3,20 +3,19 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.defaultMap import com.willfp.libreforge.Compilable -import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.applyHolder import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.mutators.emptyMutatorList import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import com.willfp.libreforge.triggers.Triggers -import com.willfp.libreforge.triggers.ifType +import com.willfp.libreforge.ifType import org.bukkit.entity.Player import org.bukkit.event.Listener import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt index e032ac88e..6a1280569 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt @@ -1,15 +1,14 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config -import com.willfp.libreforge.BlankHolder.effects import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.arguments.EffectArgumentList import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.PotentiallyTriggerable import com.willfp.libreforge.triggers.Trigger import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt index 32fa243f7..c27520227 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt @@ -6,7 +6,7 @@ import com.willfp.libreforge.NamedValue import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get object ArgumentChainArgs : EffectArgument("chain_args") { // Misusing arguments a bit here but it's surprisingly clean diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt index 056699cc2..ca9c7bd5e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt @@ -6,7 +6,6 @@ import com.willfp.eco.util.StringUtils import com.willfp.eco.util.formatEco import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NamedValue -import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effects @@ -14,7 +13,7 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.ifType +import com.willfp.libreforge.ifType import org.bukkit.Sound import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt index ad3a5d3eb..8b156cd99 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt index 7b6bbac90..63feb0ab1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt @@ -11,7 +11,7 @@ import com.willfp.libreforge.plugin import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt index 1d3c9049b..34b682a34 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.plugin import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt index fe613fb2a..facd4fadb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt @@ -2,12 +2,11 @@ package com.willfp.libreforge.effects.events import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.Event import org.bukkit.event.HandlerList -import org.bukkit.event.player.PlayerEvent class EffectDisableEvent( val dispatcher: Dispatcher<*>, diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt index 5e0552cdb..66c0d9f44 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt @@ -2,12 +2,11 @@ package com.willfp.libreforge.effects.events import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.Event import org.bukkit.event.HandlerList -import org.bukkit.event.player.PlayerEvent class EffectEnableEvent( val dispatcher: Dispatcher<*>, diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt index df8dc3f09..ccce4e460 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt @@ -3,15 +3,12 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments -import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects -import com.willfp.libreforge.effects.executors.impl.NormalExecutorFactory -import com.willfp.libreforge.effects.impl.aoe.AOEBlock import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt index 3d178adc9..d6559fb1f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt @@ -8,7 +8,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt index 48d1d1aa8..499e44f5e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt @@ -13,8 +13,8 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.registerHolderProvider -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.Objects diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt index 15f484f45..64ec03464 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.points -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt index 86a12e512..26df1e020 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt index 03c54df6a..65ecf1334 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt @@ -8,8 +8,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.triggers.Dispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerCommandPreprocessEvent import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt index 6e1025b50..6ce0368c1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.block.BrewingStand import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt index 19b0e9e4a..0685ef7fb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.Material import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt index 96e156497..fb7edab75 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.enchantment.EnchantItemEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt index ff6856d28..b39b8c001 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt @@ -6,9 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.Dispatcher import org.bukkit.Tag -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.block.Action import org.bukkit.event.player.PlayerInteractEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt index 5280e9954..0d88cfe90 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt @@ -6,8 +6,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt index b22a4d41a..be748ed87 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt index f36d6d231..3e2d4ab8f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt @@ -2,9 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.NumberUtils import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.EntityDispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent import kotlin.math.ceil diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt index 02223ec46..4afdd6f49 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt @@ -6,8 +6,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.triggers.Dispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.PlayerDeathEvent import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt index e442a5575..b99eb4027 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerRespawnEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt index fda6f119c..59a3623b1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.duration import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt index 6f8593045..75afd3796 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt index 41c04b82f..da1d0be9b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityShootBowEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt index 9d3c5b948..85acec452 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerFishEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt index 971c48702..f0bebebf9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt @@ -2,8 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiMultiplierEffect import com.willfp.libreforge.enumValueOfOrNull -import com.willfp.libreforge.triggers.EntityDispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.EntityRegainHealthEvent import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt index 79f7fe23a..aa5ca812e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt @@ -9,12 +9,11 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.Dispatcher import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.block.BlockFace import org.bukkit.block.data.Ageable -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.block.BlockBreakEvent import org.bukkit.event.block.BlockPlaceEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt index 17cd8e5a2..cf97cfa20 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt @@ -9,7 +9,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt index 5b2a57ea0..ab6ef85b3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt index f94d6234f..ae10e1ba3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler object EffectSellMultiplier : MultiplierEffect("sell_multiplier") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt index e69171a65..a135bfc99 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt @@ -12,17 +12,14 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher +import com.willfp.libreforge.Dispatcher import org.bukkit.GameMode import org.bukkit.Material -import org.bukkit.Tag import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority -import org.bukkit.event.block.Action import org.bukkit.event.block.BlockBreakEvent import org.bukkit.event.block.BlockDropItemEvent -import org.bukkit.event.player.PlayerInteractEvent import java.util.UUID object EffectTelekinesis : Effect("telekinesis") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt index cb722e132..58c919edc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt @@ -2,13 +2,10 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.ViolationContext -import com.willfp.libreforge.arguments -import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.RichChain -import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt index 32f523a02..9d391a468 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.events.NaturalExpGainEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler import kotlin.math.ceil diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt index b9415552c..641e0bedb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt @@ -6,13 +6,12 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeInstance import org.bukkit.attribute.AttributeModifier import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player abstract class AttributeEffect( id: String, diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt index b416541bd..593b92bd6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt @@ -9,9 +9,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt index 70aaa5805..1ff06ec5f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt @@ -9,9 +9,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt index 52b624b7a..37e9fc7b5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt @@ -8,9 +8,9 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt index 634350354..2f529defb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt @@ -5,10 +5,8 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.filters.Filter -import com.willfp.libreforge.triggers.EntityDispatcher -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData -import org.bukkit.entity.Player object FilterVictimConditions : Filter>("victim_conditions") { override fun getValue(config: Config, data: TriggerData?, key: String): Collection { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt index f8e8abc3f..26e8657f5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt @@ -11,7 +11,7 @@ import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt index 0bb21162f..0e271d69d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt index 3c9402ab6..1c4e28b6e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt @@ -9,8 +9,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player object EffectAddStat : Effect("add_stat") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt index 61ef14d91..c32e1ff15 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt @@ -4,7 +4,7 @@ import com.archyx.aureliumskills.api.event.XpGainEvent import com.archyx.aureliumskills.skills.Skill import com.archyx.aureliumskills.skills.Skills import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multiplier") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt index b183d75bc..fb4d3bfbb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt index 3b8d5626f..86aff43c9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt @@ -1,10 +1,9 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter -import net.citizensnpcs.api.event.NPCLeftClickEvent import net.citizensnpcs.api.event.NPCRightClickEvent import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt index 8093059cd..37f3457f8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsPaymentEvent import com.gamingmesh.jobs.container.CurrencyType import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt index de23c0dc4..72baaafe3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gamingmesh.jobs.Jobs import com.gamingmesh.jobs.api.JobsExpGainEvent import com.gamingmesh.jobs.container.Job import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt index 7e196f11b..0ac412f91 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsLevelUpEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt index 3984655b9..6bad4bc17 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent import com.gmail.nossr50.mcMMO import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_xp_multiplier") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt index bd5464180..3237e5195 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionInBubble : Condition("in_bubble") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt index b17c09ce9..9fd65a74a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionInLava : Condition("in_lava") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt index 186a3b4c0..f8c904797 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt @@ -4,10 +4,9 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Entity -import org.bukkit.entity.Player object ConditionInRain : Condition("in_rain") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt index e4fc21407..5d076337c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt @@ -13,7 +13,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.ChatColor diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt index 75f29163a..944ed5978 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.event.EventHandler object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_chance") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt index ac258a323..19a4cec1b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.block.BeaconEffectEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt index 4fd31ace6..2e512e12c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt index ee6384b0d..df9cc9a65 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt index b9c90fb45..da50167ed 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt index 5ea0d5c5f..0decda6a3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt index 692689ade..31544df61 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt index f741ba6c7..3ee712e66 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.tmmobcoins.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import net.devtm.tmmobcoins.API.MobCoinReceiveEvent import org.bukkit.event.EventHandler diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt index dc647674b..5f448509d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt @@ -2,14 +2,13 @@ package com.willfp.libreforge.integrations.vault.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap -import com.willfp.eco.core.map.nestedMap import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import net.milkbowl.vault.permission.Permission import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt index d2e2ca5dc..eba4d2a09 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt @@ -4,13 +4,11 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldedit.math.BlockVector3 import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.util.containsIgnoreCase import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.triggers.Dispatcher -import org.bukkit.entity.Player +import com.willfp.libreforge.Dispatcher object ConditionInRegion : Condition("in_region") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt index fd9ee8024..6e625b9e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.worldguard.impl import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt index 1ce04cf22..4327962f6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.worldguard.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt index ae03d4365..366a753fe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt @@ -14,7 +14,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.levels.event.ItemLevelUpEvent import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.impl.TriggerLevelUpItem import org.bukkit.Bukkit diff --git a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt index 22af40a6a..1a9ed3e0f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt @@ -11,7 +11,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.placeholders.CustomPlaceholder -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.inventory.ItemStack class ConditionalCustomPlaceholder( diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt index 6890c7e0b..fc175e12c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt @@ -1,7 +1,10 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.placeholder.InjectablePlaceholder +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NamedValue +import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.triggers.placeholders.TriggerPlaceholders import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt index ef71f538b..abd430983 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt @@ -2,6 +2,8 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt index 2e704ae76..ba101665f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt @@ -1,13 +1,18 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.registry.KRegistrable +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.ProvidedEffectBlock import com.willfp.libreforge.ProvidedEffectBlocks import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.counters.bind.BoundCounters import com.willfp.libreforge.counters.bind.BoundCounters.bindings import com.willfp.libreforge.generatePlaceholders +import com.willfp.libreforge.get import com.willfp.libreforge.getProvidedActiveEffects +import com.willfp.libreforge.ifType +import com.willfp.libreforge.isType import com.willfp.libreforge.plugin import com.willfp.libreforge.providedActiveEffects import com.willfp.libreforge.triggers.event.TriggerDispatchEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt index c6c064d8e..c14745a0d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt @@ -1,7 +1,9 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.items.HashedItem +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.EmptyProvidedHolder +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.getProvider import com.willfp.libreforge.triggers.impl.TriggerBlank diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt index edd63db53..e99d4ae0e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt @@ -1,13 +1,12 @@ package com.willfp.libreforge.triggers.event import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.Dispatcher -import com.willfp.libreforge.triggers.get +import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.Cancellable import org.bukkit.event.Event import org.bukkit.event.HandlerList -import org.bukkit.event.player.PlayerEvent class TriggerDispatchEvent( val dispatcher: Dispatcher<*>, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt index 4bac71b9d..76828762b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt index 6e6a6dfc7..f962db8d7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt index 77a7afaec..ca60f631d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt index 21ca0acac..c7b5abd15 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt @@ -1,11 +1,10 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.AbstractArrow -import org.bukkit.entity.Arrow import org.bukkit.entity.LivingEntity import org.bukkit.entity.Player import org.bukkit.entity.Trident diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt index e076bf822..a7aaf4d65 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt index aa9b05065..540c5a080 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt index 1a5954698..b8fa848d3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt index 4f999a4a0..5b503d0c3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt index c20974dc9..d14d6e005 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt index bbd766a36..eb8b38c3c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt index aeaed2e64..dae1126bb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt index f3aec7b28..132b6abbf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.ArmorChangeEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt index 53656e366..edbbec68a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt index 37f9dec44..6b6c439fe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt @@ -1,12 +1,11 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerChangedWorldEvent -import org.bukkit.event.player.PlayerMoveEvent object TriggerChangeWorld : Trigger("change_world") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt index 7f461cef4..d54ec3588 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt @@ -1,11 +1,10 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.Material -import org.bukkit.entity.LivingEntity import org.bukkit.event.EventHandler import org.bukkit.event.block.Action import org.bukkit.event.player.PlayerInteractEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt index c7ecccecd..28abe18be 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt index 003eac7f4..e99a6b38f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt index fa80a1e3b..ea63f916e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt index 6714bf263..2861e89f3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt index 1342eaccf..de0d764a0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt index 5463d58e2..eb28891b1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt index 033329fe7..a6b355acd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderDisableEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt index 89daa18a4..63bdad334 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt index 52faafb22..5c2c13f09 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt index 37454f65c..0a99b5600 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt @@ -1,12 +1,11 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerBucketEmptyEvent -import org.bukkit.event.player.PlayerBucketFillEvent object TriggerEmptyBucket : Trigger("empty_bucket") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt index 513f2f1ad..3b3ae0b75 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderEnableEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt index b5d7aacf4..1bd8ee4b6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt index fb7d404f2..5753c857f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt index 59b97a45c..4856c85fa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt @@ -5,7 +5,7 @@ import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt index 0a370b444..77267116b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt index afde7e607..3c47d7950 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt index 09bd071af..3ec1035d7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt index d86c426b0..009289d69 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt index 2fdb7f242..bfd87ed29 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.NaturalExpGainEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt index c574599d8..0e6c77f59 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt index a4e2cbf7a..0cd802318 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt index 325cea9da..de3bc4327 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt index 3fafe7fb1..f15cb8d1f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt index 892750241..99d6ff437 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt index 33c13da48..efb751754 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt index de3a449bb..98ce8a1e8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt index 80cf888e3..fa3b08ca7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt index 480898c13..293a3a1af 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.PlayerJumpEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt index 92729b733..46034fe09 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt index 0069683d4..ab9d71eae 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt index 98380314c..9ea46987a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt index b3aa9baab..3d36da106 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt index c798d1535..8bba33b5d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.levels.event.ItemLevelUpEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt index 957283314..64a5f8110 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt index 06b286f4c..9b31ba7e9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt index 9418a6d0b..f1852b2d7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt index 6cb34999a..7032e2b82 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt index 9cb7c7708..22bcbe3fe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt index c200318b9..7c544a986 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index 60471945a..8e09e7497 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt index 7cb74e66a..0db9fc799 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt index f2a130e20..fdfde9833 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt index 6c27c05dc..b5a388fb3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt index acbcc7b47..bf88b7ef6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt index f40192797..918aa6854 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt index 55c4d4422..c9d5c0a26 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt index 71aeb178c..84c168b93 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt index 88bf748b2..bca366407 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt index d6a25281a..8833e582c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt index 5f12b4041..b6f595d51 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt index 3a7fd26fd..5d899027d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt index 51372ce68..bf5453bc7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt index 63abc664b..2672a7100 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt index d394ad0de..8bb9ccca4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt index 47b93a004..a19f60a5a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt index 6aa35d6a6..bc9ac55ee 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt index ff95c5778..468265bb5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt index b51c65a7e..18bbd2401 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt @@ -1,13 +1,12 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.EntityTameEvent -import org.bukkit.event.player.PlayerSwapHandItemsEvent object TriggerTameAnimal : Trigger("tame_animal") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt index 2634d02d2..2b4142f84 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt index b353c0017..596296f48 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt index 9a5552c38..ae49fe770 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt index 5f0b07f22..0a9b81bd8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt index b741003e6..e36ab081e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.holders import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt index 98ad8a8d0..f9f09ffa9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.triggers.PlayerDispatcher +import com.willfp.libreforge.PlayerDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter From 7914d54369694ad255b82eda6d202796b79ee928 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 14:57:32 +0000 Subject: [PATCH 05/11] Unified Player and Entity dispatchers --- .../main/kotlin/com/willfp/libreforge/Dispatcher.kt | 13 ------------- .../com/willfp/libreforge/EffectCollisionFixer.kt | 2 +- .../src/main/kotlin/com/willfp/libreforge/Holder.kt | 4 ++-- .../kotlin/com/willfp/libreforge/HolderProvider.kt | 6 +++--- .../willfp/libreforge/conditions/ConditionBlock.kt | 4 ++-- .../willfp/libreforge/conditions/ConditionList.kt | 8 ++++---- .../kotlin/com/willfp/libreforge/effects/Chain.kt | 4 ++-- .../com/willfp/libreforge/effects/ChainElement.kt | 6 +++--- .../kotlin/com/willfp/libreforge/effects/Effect.kt | 6 +++--- .../com/willfp/libreforge/effects/EffectBlock.kt | 6 +++--- .../com/willfp/libreforge/effects/impl/EffectAOE.kt | 4 ++-- .../libreforge/effects/impl/EffectAOEBlocks.kt | 4 ++-- .../libreforge/effects/impl/EffectAllPlayers.kt | 4 ++-- .../effects/impl/EffectBrewTimeMultiplier.kt | 4 ++-- .../effects/impl/EffectDontConsumeLapisChance.kt | 4 ++-- .../effects/impl/EffectDontConsumeXpChance.kt | 4 ++-- .../libreforge/effects/impl/EffectFoodMultiplier.kt | 4 ++-- .../effects/impl/EffectPotionDurationMultiplier.kt | 4 ++-- .../libreforge/effects/impl/EffectRandomPlayer.kt | 4 ++-- .../effects/impl/EffectReelSpeedMultiplier.kt | 4 ++-- .../libreforge/effects/impl/EffectRunChain.kt | 4 ++-- .../libreforge/effects/impl/EffectRunChainInline.kt | 4 ++-- .../libreforge/effects/impl/EffectSellMultiplier.kt | 4 ++-- .../effects/impl/EffectTriggerNestedChain.kt | 4 ++-- .../libreforge/effects/impl/EffectXpMultiplier.kt | 4 ++-- .../effects/templates/ChanceMultiplierEffect.kt | 4 ++-- .../effects/templates/MultiMultiplierEffect.kt | 4 ++-- .../effects/templates/MultiplierEffect.kt | 4 ++-- .../aureliumskills/impl/EffectSkillXpMultiplier.kt | 4 ++-- .../citizens/impl/TriggerLeftClickNPC.kt | 4 ++-- .../citizens/impl/TriggerRightClickNPC.kt | 4 ++-- .../jobs/impl/EffectJobsMoneyMultiplier.kt | 4 ++-- .../jobs/impl/EffectJobsXpMultiplier.kt | 4 ++-- .../integrations/jobs/impl/TriggerJobsLevelUp.kt | 4 ++-- .../mcmmo/impl/EffectMcMMOXpMultiplier.kt | 4 ++-- .../integrations/paper/impl/EffectDropPickupItem.kt | 4 ++-- .../paper/impl/EffectElytraBoostSaveChance.kt | 4 ++-- .../integrations/paper/impl/TriggerBeaconEffect.kt | 4 ++-- .../integrations/paper/impl/TriggerElytraBoost.kt | 4 ++-- .../integrations/paper/impl/TriggerSwing.kt | 4 ++-- .../integrations/paper/impl/TriggerVillagerTrade.kt | 4 ++-- .../scyther/impl/TriggerScytherAutoCollect.kt | 4 ++-- .../scyther/impl/TriggerScytherAutoSell.kt | 4 ++-- .../tmmobcoins/impl/EffectMobCoinsMultiplier.kt | 4 ++-- .../worldguard/impl/TriggerEnterRegion.kt | 4 ++-- .../worldguard/impl/TriggerLeaveRegion.kt | 4 ++-- .../com/willfp/libreforge/levels/LevelType.kt | 4 ++-- .../impl/ConditionalCustomPlaceholder.kt | 4 ++-- .../willfp/libreforge/triggers/DispatchedTrigger.kt | 4 ++-- .../libreforge/triggers/DispatchedTriggerFactory.kt | 4 ++-- .../com/willfp/libreforge/triggers/Trigger.kt | 4 ++-- .../com/willfp/libreforge/triggers/TriggerData.kt | 4 ++-- .../libreforge/triggers/impl/TriggerAltClick.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerBite.kt | 4 ++-- .../triggers/impl/TriggerBlockItemDrop.kt | 4 ++-- .../libreforge/triggers/impl/TriggerBowAttack.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerBreed.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerBrew.kt | 4 ++-- .../triggers/impl/TriggerBrewIngredient.kt | 4 ++-- .../libreforge/triggers/impl/TriggerCastRod.kt | 4 ++-- .../libreforge/triggers/impl/TriggerCatchEntity.kt | 4 ++-- .../libreforge/triggers/impl/TriggerCatchFish.kt | 4 ++-- .../triggers/impl/TriggerCatchFishFail.kt | 4 ++-- .../libreforge/triggers/impl/TriggerChangeArmor.kt | 4 ++-- .../libreforge/triggers/impl/TriggerChangeChunk.kt | 4 ++-- .../libreforge/triggers/impl/TriggerChangeWorld.kt | 4 ++-- .../libreforge/triggers/impl/TriggerClickBlock.kt | 4 ++-- .../libreforge/triggers/impl/TriggerClickEntity.kt | 4 ++-- .../libreforge/triggers/impl/TriggerConsume.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerCraft.kt | 4 ++-- .../libreforge/triggers/impl/TriggerDamageItem.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerDeath.kt | 4 ++-- .../libreforge/triggers/impl/TriggerDeployElytra.kt | 4 ++-- .../libreforge/triggers/impl/TriggerDisable.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerDrink.kt | 4 ++-- .../libreforge/triggers/impl/TriggerDropItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerEmptyBucket.kt | 4 ++-- .../libreforge/triggers/impl/TriggerEnable.kt | 4 ++-- .../libreforge/triggers/impl/TriggerEnchantItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerEnterBed.kt | 4 ++-- .../triggers/impl/TriggerEntityItemDrop.kt | 4 ++-- .../libreforge/triggers/impl/TriggerEntityTarget.kt | 4 ++-- .../libreforge/triggers/impl/TriggerFallDamage.kt | 4 ++-- .../libreforge/triggers/impl/TriggerFillBucket.kt | 4 ++-- .../libreforge/triggers/impl/TriggerGainHunger.kt | 4 ++-- .../libreforge/triggers/impl/TriggerGainXp.kt | 4 ++-- .../libreforge/triggers/impl/TriggerGroupCustom.kt | 4 ++-- .../libreforge/triggers/impl/TriggerGroupStatic.kt | 4 ++-- .../libreforge/triggers/impl/TriggerHeadshot.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerHeal.kt | 4 ++-- .../libreforge/triggers/impl/TriggerHoldItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerHookInGround.kt | 4 ++-- .../libreforge/triggers/impl/TriggerItemBreak.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerJoin.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerJump.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerKill.kt | 6 +++--- .../libreforge/triggers/impl/TriggerLeashEntity.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerLeave.kt | 4 ++-- .../libreforge/triggers/impl/TriggerLeaveBed.kt | 4 ++-- .../libreforge/triggers/impl/TriggerLevelUpItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerLevelUpXp.kt | 4 ++-- .../libreforge/triggers/impl/TriggerLoseHunger.kt | 4 ++-- .../triggers/impl/TriggerLosePotionEffect.kt | 4 ++-- .../libreforge/triggers/impl/TriggerMeleeAttack.kt | 4 ++-- .../libreforge/triggers/impl/TriggerMineBlock.kt | 4 ++-- .../triggers/impl/TriggerMineBlockProgress.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerMove.kt | 4 ++-- .../libreforge/triggers/impl/TriggerPickUpItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerPlaceBlock.kt | 4 ++-- .../libreforge/triggers/impl/TriggerPotionEffect.kt | 4 ++-- .../triggers/impl/TriggerProjectileHit.kt | 6 +++--- .../triggers/impl/TriggerProjectileLaunch.kt | 4 ++-- .../libreforge/triggers/impl/TriggerReelIn.kt | 4 ++-- .../libreforge/triggers/impl/TriggerRespawn.kt | 4 ++-- .../libreforge/triggers/impl/TriggerRunCommand.kt | 4 ++-- .../libreforge/triggers/impl/TriggerSellItem.kt | 4 ++-- .../libreforge/triggers/impl/TriggerSendMessage.kt | 4 ++-- .../libreforge/triggers/impl/TriggerShearEntity.kt | 4 ++-- .../libreforge/triggers/impl/TriggerShieldBlock.kt | 4 ++-- .../libreforge/triggers/impl/TriggerShootBow.kt | 4 ++-- .../willfp/libreforge/triggers/impl/TriggerSmelt.kt | 4 ++-- .../libreforge/triggers/impl/TriggerSwapHands.kt | 4 ++-- .../libreforge/triggers/impl/TriggerTakeDamage.kt | 4 ++-- .../triggers/impl/TriggerTakeEntityDamage.kt | 4 ++-- .../libreforge/triggers/impl/TriggerTameAnimal.kt | 4 ++-- .../libreforge/triggers/impl/TriggerTeleport.kt | 4 ++-- .../libreforge/triggers/impl/TriggerToggleFlight.kt | 4 ++-- .../libreforge/triggers/impl/TriggerToggleSneak.kt | 4 ++-- .../libreforge/triggers/impl/TriggerToggleSprint.kt | 4 ++-- .../triggers/impl/TriggerTridentAttack.kt | 4 ++-- .../libreforge/triggers/impl/TriggerWinRaid.kt | 4 ++-- 131 files changed, 267 insertions(+), 280 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt index 2f229bbf6..69f552efa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt @@ -47,19 +47,6 @@ inline fun Dispatcher<*>.ifType(block: (T) -> Unit) { block(dispatcher) } -/** - * A dispatcher for a player. - */ -class PlayerDispatcher( - override val dispatcher: Player -) : Dispatcher { - override val uuid - get() = dispatcher.uniqueId - - override val location - get() = dispatcher.location -} - /** * A dispatcher for an entity. */ diff --git a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt index 150969c0a..dba09fccf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt @@ -15,7 +15,7 @@ object EffectCollisionFixer : Listener { val player = event.player for ((holder, effects) in player.providedActiveEffects) { for (effect in effects) { - effect.disable(PlayerDispatcher(player), holder) + effect.disable(EntityDispatcher(player), holder) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt index 33db78d4c..d6907d255 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt @@ -101,7 +101,7 @@ interface ProvidedHolder { * Get not met lines for a [player]. */ fun getNotMetLines(player: Player): List = - getNotMetLines(PlayerDispatcher(player)) + getNotMetLines(EntityDispatcher(player)) /** * Get if the holder is showing any not met lines for a [dispatcher], or if any @@ -117,7 +117,7 @@ interface ProvidedHolder { * conditions are not met and have showNotMet set to true (e.g. for Enchantment Strikethrough). */ fun isShowingAnyNotMet(player: Player): Boolean = - isShowingAnyNotMet(PlayerDispatcher(player)) + isShowingAnyNotMet(EntityDispatcher(player)) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 9d1c4d0b7..68a4a91db 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -254,7 +254,7 @@ fun Collection.getProvidedActiveEffects(player: Player): List() for (holder in this) { - if (holder.holder.conditions.areMet(PlayerDispatcher(player), holder)) { + if (holder.holder.conditions.areMet(EntityDispatcher(player), holder)) { blocks += ProvidedEffectBlocks(holder, holder.getActiveEffects(player)) } } @@ -266,7 +266,7 @@ fun Collection.getProvidedActiveEffects(player: Player): List internal constructor( DeprecationLevel.ERROR ) fun isMet(player: Player, holder: ProvidedHolder): Boolean = - isMet(PlayerDispatcher(player), holder) + isMet(EntityDispatcher(player), holder) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt index c1940f205..fb321461a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt @@ -5,7 +5,7 @@ import com.willfp.libreforge.DelegatedList import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player @@ -57,7 +57,7 @@ class ConditionList( DeprecationLevel.ERROR ) fun areMet(player: Player, holder: ProvidedHolder): Boolean = - areMet(PlayerDispatcher(player), holder) + areMet(EntityDispatcher(player), holder) /** * Get if any conditions are not met and should be shown. @@ -68,7 +68,7 @@ class ConditionList( DeprecationLevel.ERROR ) fun isShowingAnyNotMet(player: Player, holder: ProvidedHolder): Boolean = - isShowingAnyNotMet(PlayerDispatcher(player), holder) + isShowingAnyNotMet(EntityDispatcher(player), holder) @Deprecated( "Use getNotMetLines(dispatcher, holder) instead.", @@ -76,7 +76,7 @@ class ConditionList( DeprecationLevel.ERROR ) fun getNotMetLines(player: Player, holder: ProvidedHolder): List = - getNotMetLines(PlayerDispatcher(player), holder) + getNotMetLines(EntityDispatcher(player), holder) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt index dee5b534f..8d5db0425 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt @@ -5,7 +5,7 @@ import com.willfp.libreforge.WeightedList import com.willfp.libreforge.effects.executors.ChainExecutor import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.get @@ -52,6 +52,6 @@ class Chain internal constructor( trigger: Trigger = TriggerBlank, executor: ChainExecutor = this.executor ): Boolean { - return trigger(PlayerDispatcher(player), data, trigger, executor) + return trigger(EntityDispatcher(player), data, trigger, executor) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt index c7dedccc7..07808c69a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt @@ -12,7 +12,7 @@ import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID @@ -76,7 +76,7 @@ class ChainElement internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = enable(PlayerDispatcher(player), holder, isReload) + ) = enable(EntityDispatcher(player), holder, isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", @@ -87,5 +87,5 @@ class ChainElement internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(PlayerDispatcher(player), holder, isReload) + ) = disable(EntityDispatcher(player), holder, isReload) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt index d403726ca..aaebf4b21 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.mutators.emptyMutatorList import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -219,7 +219,7 @@ abstract class Effect( holder: ProvidedHolder, config: ChainElement, isReload: Boolean = false - ) = enable(PlayerDispatcher(player), holder, config, isReload) + ) = enable(EntityDispatcher(player), holder, config, isReload) @Deprecated( "Use enable(Dispatcher<*>, ProvidedHolder, ChainElement, Boolean)", @@ -244,7 +244,7 @@ abstract class Effect( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(PlayerDispatcher(player), holder, isReload) + ) = disable(EntityDispatcher(player), holder, isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt index 6a1280569..a147e2169 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt @@ -8,7 +8,7 @@ import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.PotentiallyTriggerable import com.willfp.libreforge.triggers.Trigger import org.bukkit.entity.Player @@ -61,7 +61,7 @@ class EffectBlock internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = enable(PlayerDispatcher(player), holder, isReload = isReload) + ) = enable(EntityDispatcher(player), holder, isReload = isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", @@ -73,7 +73,7 @@ class EffectBlock internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(PlayerDispatcher(player), holder, isReload = isReload) + ) = disable(EntityDispatcher(player), holder, isReload = isReload) fun tryTrigger(trigger: DispatchedTrigger) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt index ccce4e460..e537ea96e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt @@ -8,7 +8,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +40,7 @@ object EffectAOE : Effect("aoe") { data.copy( victim = entity, location = entity.location - ).dispatch(PlayerDispatcher(player)) + ).dispatch(EntityDispatcher(player)) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt index d6559fb1f..4ed2db6d9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt @@ -8,7 +8,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -41,7 +41,7 @@ object EffectAOEBlocks : Effect("aoe_blocks") { data.copy( block = block, location = block.location.add(0.5, 0.5, 0.5) - ).dispatch(PlayerDispatcher(player)) + ).dispatch(EntityDispatcher(player)) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt index 26df1e020..520cbb16a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -21,7 +21,7 @@ object EffectAllPlayers : Effect("all_players") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { for (player in Bukkit.getOnlinePlayers()) { compileData?.trigger( - data.dispatch(PlayerDispatcher(player)), + data.dispatch(EntityDispatcher(player)), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt index 6ce0368c1..8c91b6e92 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.block.BrewingStand import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -15,7 +15,7 @@ object EffectBrewTimeMultiplier : MultiplierEffect("brew_time_multiplier") { fun handle(event: InventoryClickEvent) { val player = event.whoClicked as? Player ?: return - val multiplier = getMultiplier(PlayerDispatcher(player)) + val multiplier = getMultiplier(EntityDispatcher(player)) if (player.openInventory.topInventory.holder !is BrewingStand) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt index 0685ef7fb..28fe27fc7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.Material import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -15,7 +15,7 @@ object EffectDontConsumeLapisChance : ChanceMultiplierEffect("dont_consume_lapis val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(PlayerDispatcher(player))) { + if (!passesChance(EntityDispatcher(player))) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt index fb7edab75..8aea50b12 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.enchantment.EnchantItemEvent @@ -13,7 +13,7 @@ object EffectDontConsumeXpChance : ChanceMultiplierEffect("dont_consume_xp_chanc val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(PlayerDispatcher(player))) { + if (!passesChance(EntityDispatcher(player))) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt index be748ed87..f8e0e6083 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent @@ -18,6 +18,6 @@ object EffectFoodMultiplier : MultiplierEffect("food_multiplier") { return } - event.foodLevel = player.foodLevel + ceil(getMultiplier(PlayerDispatcher(player)) * diff).toInt() + event.foodLevel = player.foodLevel + ceil(getMultiplier(EntityDispatcher(player)) * diff).toInt() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt index 59a3623b1..5e75f58c0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.duration import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -27,7 +27,7 @@ object EffectPotionDurationMultiplier : MultiplierEffect("potion_duration_multip val player = event.contents.viewers.filterIsInstance().firstOrNull() ?: return val multiplier = getMultiplier( - PlayerDispatcher(player) + EntityDispatcher(player) ) plugin.scheduler.run { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt index 75afd3796..4817524cb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -21,7 +21,7 @@ object EffectRandomPlayer : Effect("random_player") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { Bukkit.getOnlinePlayers().randomOrNull()?.let { player -> compileData?.trigger( - data.dispatch(PlayerDispatcher(player)), + data.dispatch(EntityDispatcher(player)), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt index 85acec452..9a9d9bc45 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerFishEvent @@ -19,7 +19,7 @@ object EffectReelSpeedMultiplier : MultiplierEffect("reel_speed_multiplier") { val player = event.player - val multiplier = getMultiplier(PlayerDispatcher(player)) + val multiplier = getMultiplier(EntityDispatcher(player)) if (multiplier == 1.0) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt index cf97cfa20..6a4a3c4bd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt @@ -9,7 +9,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object EffectRunChain : Effect("run_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(PlayerDispatcher(player)) + val dispatch = data.dispatch(EntityDispatcher(player)) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt index ab6ef85b3..49609f8b8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object EffectRunChainInline : Effect("run_chain_inline") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(PlayerDispatcher(player)) + val dispatch = data.dispatch(EntityDispatcher(player)) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt index ae10e1ba3..68f16bc83 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt @@ -2,12 +2,12 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler object EffectSellMultiplier : MultiplierEffect("sell_multiplier") { @EventHandler fun handle(event: ShopSellEvent) { - event.multiplier *= getMultiplier(PlayerDispatcher(event.player)) + event.multiplier *= getMultiplier(EntityDispatcher(event.player)) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt index 58c919edc..d05d8349a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt @@ -5,7 +5,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.RichChain -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +24,7 @@ object EffectTriggerNestedChain : Effect("trigger_nested_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: RichChain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(PlayerDispatcher(player)) + val dispatch = data.dispatch(EntityDispatcher(player)) return compileData?.trigger(dispatch) == true } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt index 9d391a468..b6d9ebfeb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.events.NaturalExpGainEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler import kotlin.math.ceil @@ -11,7 +11,7 @@ object EffectXpMultiplier : MultiplierEffect("xp_multiplier") { fun handle(event: NaturalExpGainEvent) { val player = event.expChangeEvent.player - val multiplier = getMultiplier(PlayerDispatcher(player)) + val multiplier = getMultiplier(EntityDispatcher(player)) event.expChangeEvent.amount = ceil(event.expChangeEvent.amount * multiplier).toInt() } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt index 593b92bd6..27ff006c8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID @@ -54,5 +54,5 @@ abstract class ChanceMultiplierEffect(id: String) : Effect(id) { DeprecationLevel.ERROR ) protected fun passesChance(player: Player): Boolean = - passesChance(PlayerDispatcher(player)) + passesChance(EntityDispatcher(player)) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt index 1ff06ec5f..e880b4aad 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt @@ -10,7 +10,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID @@ -78,7 +78,7 @@ abstract class MultiMultiplierEffect(id: String) : Effect(id) { DeprecationLevel.ERROR ) protected fun getMultiplier(player: Player): Double = - getMultiplier(PlayerDispatcher(player)) + getMultiplier(EntityDispatcher(player)) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt index c32e1ff15..e971fffd3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt @@ -4,7 +4,7 @@ import com.archyx.aureliumskills.api.event.XpGainEvent import com.archyx.aureliumskills.skills.Skill import com.archyx.aureliumskills.skills.Skills import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multiplier") { @@ -22,7 +22,7 @@ object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multipli fun handle(event: XpGainEvent) { val player = event.player - val multiplier = getMultiplier(PlayerDispatcher(player), event.skill) + val multiplier = getMultiplier(EntityDispatcher(player), event.skill) event.amount *= multiplier } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt index fb4d3bfbb..547d49804 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerLeftClickNPC : Trigger("left_click_npc") { val player = event.clicker ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt index 86aff43c9..91cd65e39 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerRightClickNPC : Trigger("right_click_npc") { val player = event.clicker ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt index 37f3457f8..f98390f1e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsPaymentEvent import com.gamingmesh.jobs.container.CurrencyType import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -12,7 +12,7 @@ object EffectJobsMoneyMultiplier : MultiplierEffect("jobs_money_multiplier") { fun handle(event: JobsPaymentEvent) { val player = event.player as? Player ?: return - val multiplier = getMultiplier(PlayerDispatcher(player)) + val multiplier = getMultiplier(EntityDispatcher(player)) var money = event.payment[CurrencyType.MONEY] ?: return money *= multiplier diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt index 72baaafe3..6620f236b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gamingmesh.jobs.Jobs import com.gamingmesh.jobs.api.JobsExpGainEvent import com.gamingmesh.jobs.container.Job import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -23,6 +23,6 @@ object EffectJobsXpMultiplier : MultiMultiplierEffect("jobs_xp_multiplier") fun handle(event: JobsExpGainEvent) { val player = event.player as? Player ?: return - event.exp *= getMultiplier(PlayerDispatcher(player), event.job) + event.exp *= getMultiplier(EntityDispatcher(player), event.job) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt index 0ac412f91..c71524a53 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsLevelUpEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerJobsLevelUp : Trigger("jobs_level_up") { val player = event.player.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt index 6bad4bc17..04d681237 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent import com.gmail.nossr50.mcMMO import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_xp_multiplier") { @@ -22,6 +22,6 @@ object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_ fun handle(event: McMMOPlayerXpGainEvent) { val player = event.player - event.rawXpGained *= getMultiplier(PlayerDispatcher(player), event.skill).toFloat() + event.rawXpGained *= getMultiplier(EntityDispatcher(player), event.skill).toFloat() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt index 5d076337c..84e85e20a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt @@ -13,7 +13,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.ChatColor @@ -49,7 +49,7 @@ object EffectDropPickupItem : Effect("drop_pickup_item") { val meta = Meta( chain, - data.dispatch(PlayerDispatcher(player)), + data.dispatch(EntityDispatcher(player)), glowColor?.let { TeamUtils.fromChatColor(it) } ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt index 944ed5978..81b34bf04 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.event.EventHandler object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_chance") { @@ -10,7 +10,7 @@ object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_c fun handle(event: PlayerElytraBoostEvent) { val player = event.player - if (passesChance(PlayerDispatcher(player))) { + if (passesChance(EntityDispatcher(player))) { event.setShouldConsume(false) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt index 19a4cec1b..b8d80d372 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.block.BeaconEffectEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerBeaconEffect : Trigger("beacon_effect") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt index 2e512e12c..5bc6964e2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerElytraBoost : Trigger("elytra_boost") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt index df9cc9a65..72a9c07f9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerSwing : Trigger("swing") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt index da50167ed..43b512731 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerVillagerTrade : Trigger("villager_trade") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = event.villager, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt index 0decda6a3..b447d947b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerScytherAutoCollect : Trigger("scyther_auto_collect") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutocollectEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt index 31544df61..1d445346b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerScytherAutoSell : Trigger("scyther_auto_sell") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutosellEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt index 3ee712e66..b5d1e571a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.tmmobcoins.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import net.devtm.tmmobcoins.API.MobCoinReceiveEvent import org.bukkit.event.EventHandler @@ -10,6 +10,6 @@ object EffectMobCoinsMultiplier : MultiplierEffect("mob_coins_multiplier") { fun handle(event: MobCoinReceiveEvent) { val player = event.player - event.setDropAmount(event.obtainedAmount * getMultiplier(PlayerDispatcher(player))) + event.setDropAmount(event.obtainedAmount * getMultiplier(EntityDispatcher(player))) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt index 6e625b9e1..26b1016a6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.worldguard.impl import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -55,7 +55,7 @@ object TriggerEnterRegion : Trigger("enter_region") { for (region in entered) { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt index 4327962f6..bcf9d0e77 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.worldguard.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +15,7 @@ object TriggerLeaveRegion : Trigger("leave_region") { fun dispatch(player: Player, event: RegionEvent) { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt index 366a753fe..678520214 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt @@ -14,7 +14,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.levels.event.ItemLevelUpEvent import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.impl.TriggerLevelUpItem import org.bukkit.Bukkit @@ -64,7 +64,7 @@ class LevelType( levelUpEffects?.trigger( DispatchedTrigger( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerLevelUpItem, TriggerData( player = player, diff --git a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt index 1a9ed3e0f..e74041662 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt @@ -11,7 +11,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.placeholders.CustomPlaceholder -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.inventory.ItemStack class ConditionalCustomPlaceholder( @@ -40,7 +40,7 @@ class ConditionalCustomPlaceholder( val holder = BlankItemHolder(ctx.itemStack) val value = values - .firstOrNull { it.conditions.areMet(PlayerDispatcher(player), holder) } + .firstOrNull { it.conditions.areMet(EntityDispatcher(player), holder) } ?.expr ?: return defaultExpr?.let { parseValue(it, ctx) } return parseValue(value, ctx) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt index fc175e12c..5fe0c6b8a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.placeholder.InjectablePlaceholder import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NamedValue -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.triggers.placeholders.TriggerPlaceholders import org.bukkit.entity.Player @@ -35,7 +35,7 @@ data class DispatchedTrigger( player: Player, trigger: Trigger, data: TriggerData, - ) : this(PlayerDispatcher(player), trigger, data) + ) : this(EntityDispatcher(player), trigger, data) fun addPlaceholder(placeholder: NamedValue) { _placeholders += placeholder diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt index abd430983..1a5a262e4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.map.listMap import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import org.bukkit.entity.Player import java.util.UUID @@ -24,7 +24,7 @@ class DispatchedTriggerFactory( DeprecationLevel.ERROR ) fun create(player: Player, trigger: Trigger, data: TriggerData): DispatchedTrigger? { - return create(PlayerDispatcher(player), trigger, data) + return create(EntityDispatcher(player), trigger, data) } fun create(dispatcher: Dispatcher<*>, trigger: Trigger, data: TriggerData): DispatchedTrigger? { diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt index ba101665f..49b438546 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.registry.KRegistrable import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.ProvidedEffectBlock import com.willfp.libreforge.ProvidedEffectBlocks import com.willfp.libreforge.ProvidedHolder @@ -50,7 +50,7 @@ abstract class Trigger( player: Player, data: TriggerData, forceHolders: Collection? = null - ) = dispatch(PlayerDispatcher(player), data, forceHolders) + ) = dispatch(EntityDispatcher(player), data, forceHolders) /** * Dispatch the trigger. diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt index c14745a0d..c7486b4ba 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.items.HashedItem import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.EmptyProvidedHolder -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.getProvider import com.willfp.libreforge.triggers.impl.TriggerBlank @@ -57,7 +57,7 @@ data class TriggerData( DeprecationLevel.ERROR ) fun dispatch(player: Player) = - dispatch(PlayerDispatcher(player)) + dispatch(EntityDispatcher(player)) /** * Turn into a dispatched trigger for a [dispatcher]. diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt index 76828762b..09f54b6c0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -131,7 +131,7 @@ object TriggerAltClick : Trigger("alt_click") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt index f962db8d7..5652ce8e9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerBite : Trigger("bite") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt index ca60f631d..866cdf53a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -49,7 +49,7 @@ object TriggerBlockItemDrop : Trigger("block_item_drop") { val editableEvent = EditableBlockDropEvent(event) this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, block = BrokenBlock(block, event.blockState.type), // Fixes the type always being AIR diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt index c7b5abd15..1a18c3594 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -45,7 +45,7 @@ object TriggerBowAttack : Trigger("bow_attack") { } this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt index a7aaf4d65..db614b036 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerBreed : Trigger("breed") { val player = event.breeder as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt index 540c5a080..667d9b972 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -53,7 +53,7 @@ object TriggerBrew : Trigger("brew") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt index b8fa848d3..2792646e6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -49,7 +49,7 @@ object TriggerBrewIngredient : Trigger("brew_ingredient") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = event.contents.ingredient, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt index 5b503d0c3..90fa456d1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCastRod : Trigger("cast_rod") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt index d14d6e005..ff5994fa9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerCatchEntity : Trigger("catch_entity") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.caught?.location ?: player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt index eb8b38c3c..3815c0a4e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCatchFish : Trigger("catch_fish") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt index dae1126bb..8b50f3a0e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCatchFishFail : Trigger("catch_fish_fail") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt index 132b6abbf..317edf9d4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.ArmorChangeEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerChangeArmor : Trigger("change_armor") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt index edbbec68a..8685e017c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerChangeChunk : Trigger("change_chunk") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt index 6b6c439fe..4afa5acee 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerChangeWorld : Trigger("change_world") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt index d54ec3588..45a812f82 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +40,7 @@ object TriggerClickBlock : Trigger("click_block") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = block.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt index 28abe18be..e0b55f809 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerClickEntity : Trigger("click_entity") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt index e99a6b38f..61222ef13 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerConsume : Trigger("consume") { fun handle(event: PlayerItemConsumeEvent) { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt index ea63f916e..ee64bf914 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -92,7 +92,7 @@ object TriggerCraft : Trigger("craft") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt index 2861e89f3..7fb7f2997 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerDamageItem : Trigger("damage_item") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt index de0d764a0..f3ef1625b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerDeath : Trigger("death") { val player = event.entity this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt index eb28891b1..c57acefc2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerDeployElytra : Trigger("deploy_elytra") { val player = event.entity as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt index a6b355acd..99844c969 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderDisableEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerDisable : Trigger("disable") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt index 63bdad334..aa583fb40 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -32,7 +32,7 @@ object TriggerDrink : Trigger("drink") { } val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt index 5c2c13f09..0f0fbd493 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerDropItem : Trigger("drop_item") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = event.itemDrop.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt index 0a99b5600..c5355c9dd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerEmptyBucket : Trigger("empty_bucket") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt index 3b3ae0b75..a54594f48 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderEnableEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerEnable : Trigger("enable") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt index 1bd8ee4b6..433873ec9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerEnchantItem : Trigger("enchant_item") { val item = event.item this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt index 5753c857f..5eaf59e8e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerEnterBed : Trigger("enter_bed") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt index 4856c85fa..e1e4c5721 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt @@ -5,7 +5,7 @@ import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -36,7 +36,7 @@ object TriggerEntityItemDrop : Trigger("entity_item_drop") { val editableEvent = EditableEntityDropEvent(event.deathEvent) this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt index 77267116b..5d2b11fd0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerEntityTarget : Trigger("entity_target") { val entity = event.entity as? LivingEntity ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt index 3c47d7950..f3ee34084 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -28,7 +28,7 @@ object TriggerFallDamage : Trigger("fall_damage") { } this.dispatch( - PlayerDispatcher(victim), + EntityDispatcher(victim), TriggerData( player = victim, location = victim.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt index 3ec1035d7..b8f1cda9f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerFillBucket : Trigger("fill_bucket") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt index 009289d69..aca748556 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerGainHunger : Trigger("gain_hunger") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt index bfd87ed29..b74f5a320 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.NaturalExpGainEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerGainXp : Trigger("gain_xp") { val player = event.expChangeEvent.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event.expChangeEvent, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt index 0e6c77f59..4abff62a8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -26,7 +26,7 @@ object TriggerGroupCustom : TriggerGroup("custom") { fun dispatch(player: Player, data: TriggerData) { super.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), data, null ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt index 0cd802318..6838686e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -52,7 +52,7 @@ object TriggerGroupStatic : TriggerGroup("static") { } else null this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt index de3bc4327..a9006e2b9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -31,7 +31,7 @@ object TriggerHeadshot : Trigger("headshot") { } this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt index f15cb8d1f..a9d03c69f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerHeal : Trigger("heal") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt index 99d6ff437..230d81596 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerHoldItem : Trigger("hold_item") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt index efb751754..cdc74cee1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerHookInGround : Trigger("hook_in_ground") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt index 98ce8a1e8..0e6368dae 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerItemBreak : Trigger("item_break") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt index fa3b08ca7..d7df4dc9a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerJoin : Trigger("join") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerJoinEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt index 293a3a1af..f564a4c34 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.PlayerJumpEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerJump : Trigger("jump") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt index 46034fe09..a15f0e120 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerKill : Trigger("kill") { val victim = event.victim this.dispatch( - PlayerDispatcher(killer), + EntityDispatcher(killer), TriggerData( player = killer, victim = victim, @@ -38,7 +38,7 @@ object TriggerKill : Trigger("kill") { fun force(player: Player, victim: LivingEntity) { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt index ab9d71eae..7d9b24c6b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerLeashEntity : Trigger("leash_entity") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt index 9ea46987a..8104f8b9c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerLeave : Trigger("leave") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerQuitEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt index 3d36da106..39a815f87 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerLeaveBed : Trigger("leave_bed") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt index 8bba33b5d..d0703ad5d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.levels.event.ItemLevelUpEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerLevelUpItem : Trigger("level_up_item") { @EventHandler fun handle(event: ItemLevelUpEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, item = event.item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt index 64a5f8110..9908d849b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerLevelUpXp : Trigger("level_up_xp") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, value = event.newLevel.toDouble() diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt index 9b31ba7e9..458a2cfd4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerLoseHunger : Trigger("lose_hunger") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt index f1852b2d7..e11e6e999 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -28,7 +28,7 @@ object TriggerLosePotionEffect : Trigger("lose_potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt index 7032e2b82..469996349 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -29,7 +29,7 @@ object TriggerMeleeAttack : Trigger("melee_attack") { } this.dispatch( - PlayerDispatcher(attacker), + EntityDispatcher(attacker), TriggerData( player = attacker, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt index 22bcbe3fe..14202fb41 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerMineBlock : Trigger("mine_block") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt index 7c544a986..d3fdc477f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerMineBlockProgress : Trigger("mine_block_progress") { val block = event.block this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index 8e09e7497..a22f17a36 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -34,7 +34,7 @@ object TriggerMove : Trigger("move") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt index 0db9fc799..cef67491f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerPickUpItem : Trigger("pick_up_item") { val player = event.entity as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = event.item.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt index fdfde9833..c1783f7da 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerPlaceBlock : Trigger("place_block") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt index b5a388fb3..8c6aee5bc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +24,7 @@ object TriggerPotionEffect : Trigger("potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt index bf88b7ef6..f7327068d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -32,7 +32,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { } this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, projectile = projectile, @@ -51,7 +51,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { val player = arrow.shooter as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt index 918aa6854..428105e99 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerProjectileLaunch : Trigger("projectile_launch") { } this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, projectile = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt index c9d5c0a26..a78639b60 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerReelIn : Trigger("reel_in") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt index 84c168b93..25ac2d5ab 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerRespawn : Trigger("respawn") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerRespawnEvent) { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt index bca366407..6dadf869e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerRunCommand : Trigger("run_command") { plugin.scheduler.run { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt index 8833e582c..4b1403167 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerSellItem : Trigger("sell_item") { val item = event.item this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt index b6f595d51..fa1044a1b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerSendMessage : Trigger("send_message") { plugin.scheduler.run { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt index 5d899027d..face3d3b5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerShearEntity : Trigger("shear_entity") { } this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt index bf5453bc7..6fd57d90a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -36,7 +36,7 @@ object TriggerShieldBlock : Trigger("shield_block") { } this.dispatch( - PlayerDispatcher(victim), + EntityDispatcher(victim), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt index 2672a7100..f419822cc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerShootBow : Trigger("shoot_bow") { } this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, projectile = event.projectile as? Projectile, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt index 8bb9ccca4..efedd48be 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerSmelt : Trigger("smelt") { val item = event.result this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt index a19f60a5a..f4169ca27 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerSwapHands : Trigger("swap_hands") { } this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt index bc9ac55ee..9703ace18 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -39,7 +39,7 @@ object TriggerTakeDamage : Trigger("take_damage") { } this.dispatch( - PlayerDispatcher(victim), + EntityDispatcher(victim), TriggerData( player = victim, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt index 468265bb5..ed7b6295d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -37,7 +37,7 @@ object TriggerTakeEntityDamage : Trigger("take_entity_damage") { } this.dispatch( - PlayerDispatcher(victim), + EntityDispatcher(victim), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt index 18bbd2401..600ad1fa8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerTameAnimal : Trigger("tame_animal") { val player = event.owner as? Player ?: return this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt index 2b4142f84..b6a3baba6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerTeleport : Trigger("teleport") { fun handle(event: PlayerTeleportEvent) { plugin.scheduler.run { this.dispatch( - PlayerDispatcher(event.player), + EntityDispatcher(event.player), TriggerData( player = event.player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt index 596296f48..736813e50 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleFlight : Trigger("toggle_flight") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt index ae49fe770..ffd71d62e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleSneak : Trigger("toggle_sneak") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt index 0a9b81bd8..8754b9260 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleSprint : Trigger("toggle_sprint") { val player = event.player this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt index e36ab081e..e235d5eb3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.holders import com.willfp.libreforge.plugin -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -53,7 +53,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { @Suppress("UNCHECKED_CAST") this.dispatch( - PlayerDispatcher(shooter), + EntityDispatcher(shooter), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt index f9f09ffa9..c528d7775 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.PlayerDispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +17,7 @@ object TriggerWinRaid : Trigger("win_raid") { fun handle(event: RaidFinishEvent) { for (player in event.winners) { this.dispatch( - PlayerDispatcher(player), + EntityDispatcher(player), TriggerData( player = player, location = event.raid.location, From 775c0ca29e92d2896b670e60d79e6746258f285b Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 15:42:26 +0000 Subject: [PATCH 06/11] Holders are now held by Dispatchers --- .../com/willfp/libreforge/Dispatcher.kt | 3 +- .../willfp/libreforge/EffectCollisionFixer.kt | 15 +- .../com/willfp/libreforge/HolderProvider.kt | 215 ++++++++++++------ .../com/willfp/libreforge/HolderUpdates.kt | 20 +- .../libreforge/LibreforgeSpigotPlugin.kt | 19 +- .../willfp/libreforge/ProvidedHolderConfig.kt | 4 +- .../impl/ConditionAboveHealthPercent.kt | 9 +- .../impl/ConditionAboveHungerPercent.kt | 5 +- .../conditions/impl/ConditionAboveXPLevel.kt | 4 +- .../impl/ConditionBelowHealthPercent.kt | 9 +- .../impl/ConditionBelowHungerPercent.kt | 5 +- .../conditions/impl/ConditionBelowXPLevel.kt | 5 +- .../conditions/impl/ConditionIsGliding.kt | 5 +- .../conditions/impl/ConditionIsSneaking.kt | 4 +- .../conditions/impl/ConditionIsSprinting.kt | 4 +- .../conditions/impl/ConditionIsStorm.kt | 6 +- .../conditions/impl/ConditionIsSwimming.kt | 5 +- .../conditions/impl/ConditionOnFire.kt | 6 +- .../conditions/impl/ConditionRidingEntity.kt | 9 +- .../effects/impl/EffectAddHolder.kt | 6 +- .../effects/impl/EffectAddHolderInRadius.kt | 20 +- .../effects/impl/EffectAddHolderToVictim.kt | 4 +- .../impl/EffectAddPermanentHolderInRadius.kt | 18 +- .../effects/impl/EffectConsumeHeldItem.kt | 4 +- .../aureliumskills/impl/ConditionHasMana.kt | 6 +- .../com/willfp/libreforge/triggers/Trigger.kt | 20 +- .../willfp/libreforge/triggers/Triggers.kt | 2 + .../triggers/impl/TriggerDisable.kt | 8 +- .../libreforge/triggers/impl/TriggerEnable.kt | 8 +- .../triggers/impl/TriggerGroupGlobalStatic.kt | 40 ++++ .../triggers/impl/TriggerTridentAttack.kt | 4 +- 31 files changed, 327 insertions(+), 165 deletions(-) create mode 100644 core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt diff --git a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt index 69f552efa..1f288781f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt @@ -1,5 +1,6 @@ package com.willfp.libreforge +import io.papermc.paper.math.Position.block import org.bukkit.Location import org.bukkit.entity.Entity import org.bukkit.entity.Player @@ -44,7 +45,7 @@ inline fun Dispatcher<*>.isType(): Boolean { */ inline fun Dispatcher<*>.ifType(block: (T) -> Unit) { val dispatcher = this.dispatcher as? T ?: return - block(dispatcher) + return block(dispatcher) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt index dba09fccf..2e797dc3b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt @@ -13,30 +13,33 @@ object EffectCollisionFixer : Listener { @EventHandler(priority = EventPriority.LOWEST) fun clearOnQuit(event: PlayerQuitEvent) { val player = event.player - for ((holder, effects) in player.providedActiveEffects) { + val dispatcher = EntityDispatcher(player) + + for ((holder, effects) in dispatcher.providedActiveEffects) { for (effect in effects) { - effect.disable(EntityDispatcher(player), holder) + effect.disable(dispatcher, holder) } } // Extra fix for pre-4.2.3 player.fixAttributes() - player.updateHolders() - player.purgePreviousHolders() + dispatcher.updateHolders() + dispatcher.purgePreviousHolders() } @EventHandler(priority = EventPriority.LOWEST) fun scanOnJoin(event: PlayerJoinEvent) { val player = event.player + val dispatcher = EntityDispatcher(player) // Extra fix for pre-4.2.3 player.fixAttributes() - player.updateHolders() + dispatcher.updateHolders() plugin.scheduler.run { - player.updateEffects() + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 68a4a91db..66890c2d6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -2,11 +2,12 @@ package com.willfp.libreforge import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.GlobalDispatcher.dispatcher import com.willfp.libreforge.effects.EffectBlock import org.bukkit.Bukkit import org.bukkit.entity.Player +import org.bukkit.event.Event import org.bukkit.event.HandlerList -import org.bukkit.event.player.PlayerEvent import java.util.UUID import java.util.concurrent.TimeUnit @@ -17,13 +18,13 @@ interface HolderProvider { /** * Provide the holders. */ - fun provide(player: Player): Collection + fun provide(dispatcher: Dispatcher<*>): Collection } class HolderProvideEvent( - who: Player, + val dispatcher: Dispatcher<*>, val holders: Collection -) : PlayerEvent(who) { +) : Event() { override fun getHandlers() = handlerList companion object { @@ -37,10 +38,10 @@ class HolderProvideEvent( } class HolderEnableEvent( - who: Player, + val dispatcher: Dispatcher<*>, val holder: ProvidedHolder, val newHolders: Collection -) : PlayerEvent(who) { +) : Event() { override fun getHandlers() = handlerList companion object { @@ -54,10 +55,10 @@ class HolderEnableEvent( } class HolderDisableEvent( - who: Player, + val dispatcher: Dispatcher<*>, val holder: ProvidedHolder, val previousHolders: Collection -) : PlayerEvent(who) { +) : Event() { override fun getHandlers() = handlerList companion object { @@ -103,69 +104,96 @@ fun registerHolderProvider(provider: HolderProvider) = providers.add(provider) /** * Register a new holder provider. */ +@Deprecated( + "Use registerHolderProvider instead", + ReplaceWith("registerHolderProvider(provider)"), + DeprecationLevel.ERROR +) fun registerHolderProvider(provider: (Player) -> Collection) = registerHolderProvider(object : HolderProvider { - override fun provide(player: Player) = provider(player) + override fun provide(dispatcher: Dispatcher<*>): Collection { + dispatcher.ifType { + return provider(it) + } + + return emptyList() + } + }) + +/** + * Register a new holder provider. + */ +fun registerDispatcherHolderProvider(provider: (Dispatcher<*>) -> Collection) = + registerHolderProvider(object : HolderProvider { + override fun provide(dispatcher: Dispatcher<*>) = provider(dispatcher) }) -private val playerRefreshFunctions = mutableListOf<(Player) -> Unit>() +private val refreshFunctions = mutableListOf<(Dispatcher<*>) -> Unit>() /** - * Register a function to be called when a player's holders are refreshed. + * Register a function to be called when a dispatcher's holders are refreshed. */ +fun registerRefreshFunction(function: (Dispatcher<*>) -> Unit) { + refreshFunctions += function +} + +@Deprecated( + "Use registerRefreshFunction instead", + ReplaceWith("registerRefreshFunction(function)"), + DeprecationLevel.ERROR +) fun registerPlayerRefreshFunction(function: (Player) -> Unit) { - playerRefreshFunctions += function + refreshFunctions += { + it.get()?.let { player -> + function(player) + } + } } /** * Update holders, effects, and call refresh functions. */ -fun Player.refreshHolders() { - playerRefreshFunctions.forEach { it(this) } +fun Dispatcher<*>.refreshHolders() { + refreshFunctions.forEach { it(this) } this.updateHolders() this.updateEffects() } -private val holderPlaceholderProviders = mutableListOf<(ProvidedHolder, Player) -> Collection>() +@Deprecated( + "Use refreshHolders on a dispatcher instead", + ReplaceWith("refreshHolders()"), + DeprecationLevel.ERROR +) +fun Player.refreshHolders() = + EntityDispatcher(this).refreshHolders() + +private val holderPlaceholderProviders = mutableListOf<(ProvidedHolder, Dispatcher<*>) -> Collection>() /** * Register a function to generate placeholders for a holder. */ -fun registerPlaceholderProvider(provider: (ProvidedHolder, Player) -> Collection) { +fun registerPlaceholderProvider(provider: (ProvidedHolder, Dispatcher<*>) -> Collection) { holderPlaceholderProviders += provider } /** * Register a function to generate placeholders for a holder. */ -inline fun registerHolderPlaceholderProvider(crossinline provider: (T, Player) -> Collection) = - registerPlaceholderProvider { providedHolder, player -> - val holder = providedHolder.holder +inline fun registerHolderPlaceholderProvider(crossinline provider: (T, Dispatcher<*>) -> Collection) { + registerPlaceholderProvider { holder, dispatcher -> if (holder is T) { - provider(holder, player) - } else { - emptyList() - } - } - -/** - * Register a function to generate placeholders for a holder. - */ -inline fun registerProviderPlaceholderProvider(crossinline provider: (T, Player) -> Collection) = - registerPlaceholderProvider { providedHolder, player -> - val holderProvider = providedHolder.provider - if (holderProvider is T) { - provider(holderProvider, player) + provider(holder, dispatcher) } else { emptyList() } } +} /** * Generate placeholders for a holder. */ -fun ProvidedHolder.generatePlaceholders(player: Player): List { - return holderPlaceholderProviders.flatMap { it(this, player) } +fun ProvidedHolder.generatePlaceholders(dispatcher: Dispatcher<*>): List { + return holderPlaceholderProviders.flatMap { it(this, dispatcher) } } private val previousHolders = mutableMapOf>() @@ -177,15 +205,15 @@ private val holderCache = Caffeine.newBuilder() /** * The holders. */ -val Player.holders: Collection - get() = holderCache.get(this.uniqueId) { +val Dispatcher<*>.holders: Collection + get() = holderCache.get(this.uuid) { val holders = providers.flatMap { it.provide(this) } Bukkit.getPluginManager().callEvent( HolderProvideEvent(this, holders) ) - val old = previousHolders[this.uniqueId] ?: emptyList() + val old = previousHolders[this.uuid] ?: emptyList() val newID = holders.map { it.holder.id } val oldID = old.map { it.holder.id } @@ -208,23 +236,36 @@ val Player.holders: Collection ) } - previousHolders[this.uniqueId] = holders + previousHolders[this.uuid] = holders holders } +@Deprecated( + "Use a dispatcher instead of a player", + ReplaceWith("holders"), + DeprecationLevel.ERROR +) +val Player.holders: Collection + get() = EntityDispatcher(this).holders + /** * Invalidate holder cache to force rescan. */ -fun Player.updateHolders() { - holderCache.invalidate(this.uniqueId) +fun Dispatcher<*>.updateHolders() { + holderCache.invalidate(this.uuid) } -/** - * Purge previous known holders. - */ -fun Player.purgePreviousHolders() { - previousHolders.remove(this.uniqueId) +@Deprecated( + "Use updateHolders on a dispatcher instead", + ReplaceWith("updateHolders()"), + DeprecationLevel.ERROR +) +fun Player.updateHolders() = + EntityDispatcher(this).updateHolders() + +fun Dispatcher<*>.purgePreviousHolders() { + previousHolders.remove(this.uuid) } // Effects that were active on previous update @@ -247,54 +288,94 @@ fun Collection.flatten(): List { } /** - * Get active effects for a [player] from holders mapped to the holder + * Get active effects for a [dispatcher] from holders mapped to the holder * that has provided them. */ -fun Collection.getProvidedActiveEffects(player: Player): List { +fun Collection.getProvidedActiveEffects(dispatcher: Dispatcher<*>): List { val blocks = mutableListOf() for (holder in this) { - if (holder.holder.conditions.areMet(EntityDispatcher(player), holder)) { - blocks += ProvidedEffectBlocks(holder, holder.getActiveEffects(player)) + if (holder.holder.conditions.areMet(dispatcher, holder)) { + blocks += ProvidedEffectBlocks(holder, holder.getActiveEffects(dispatcher)) } } return blocks } +@Deprecated( + "Use getProvidedActiveEffects on a dispatcher instead", + ReplaceWith("getProvidedActiveEffects(dispatcher)"), + DeprecationLevel.ERROR +) +fun Collection.getProvidedActiveEffects(player: Player): List = + this.getProvidedActiveEffects(EntityDispatcher(player)) + /** - * Get active effects for a [player]. + * Get active effects for a [dispatcher]. */ +fun ProvidedHolder.getActiveEffects(dispatcher: Dispatcher<*>) = + this.holder.effects.filter { it.conditions.areMet(dispatcher, this) }.toSet() + +@Deprecated( + "Use getActiveEffects on a dispatcher instead", + ReplaceWith("getActiveEffects(dispatcher)"), + DeprecationLevel.ERROR +) fun ProvidedHolder.getActiveEffects(player: Player) = - this.holder.effects.filter { it.conditions.areMet(EntityDispatcher(player), this) }.toSet() + getActiveEffects(EntityDispatcher(player)) /** * Recalculate active effects. */ -fun Player.calculateActiveEffects() = +fun Dispatcher<*>.calculateActiveEffects() = this.holders.getProvidedActiveEffects(this) +@Deprecated( + "Use calculateActiveEffects on a dispatcher instead", + ReplaceWith("calculateActiveEffects()"), + DeprecationLevel.ERROR +) +fun Player.calculateActiveEffects() = + EntityDispatcher(this).calculateActiveEffects() + /** * The active effects. */ +val Dispatcher<*>.activeEffects: List + get() = flattenedPreviousStates[this.uuid].map { it.effect } + +@Deprecated( + "Use activeEffects on a dispatcher instead", + ReplaceWith("activeEffects"), + DeprecationLevel.ERROR +) val Player.activeEffects: List - get() = flattenedPreviousStates[this.uniqueId].map { it.effect } + get() = EntityDispatcher(this).activeEffects /** * The active effects mapped to the holder that provided them. */ +val Dispatcher<*>.providedActiveEffects: List + get() = previousStates[this.uuid] + +@Deprecated( + "Use providedActiveEffects on a dispatcher instead", + ReplaceWith("providedActiveEffects"), + DeprecationLevel.ERROR +) val Player.providedActiveEffects: List - get() = previousStates[this.uniqueId] + get() = EntityDispatcher(this).providedActiveEffects /** * Update the active effects. */ -fun Player.updateEffects() { +fun Dispatcher<*>.updateEffects() { val before = this.providedActiveEffects val after = this.calculateActiveEffects() - previousStates[this.uniqueId] = after - flattenedPreviousStates[this.uniqueId] = after.flatten() + previousStates[this.uuid] = after + flattenedPreviousStates[this.uuid] = after.flatten() val beforeF = before.flatten() val afterF = after.flatten() @@ -304,14 +385,12 @@ fun Player.updateEffects() { val removed = (beforeF without afterF).sorted() val toReload = (afterF without added).sorted() - val dispatcher = EntityDispatcher(this) - for ((effect, holder) in removed) { - effect.disable(dispatcher, holder) + effect.disable(this, holder) } for ((effect, holder) in added) { - effect.enable(dispatcher, holder) + effect.enable(this, holder) } // Reloading is now done by disabling all, then enabling all. Effect#reload is deprecated. @@ -319,14 +398,22 @@ fun Player.updateEffects() { // order as mixing weights is not a concern. for ((effect, holder) in toReload) { - effect.disable(dispatcher, holder, isReload = true) + effect.disable(this, holder, isReload = true) } for ((effect, holder) in toReload) { - effect.enable(dispatcher, holder, isReload = true) + effect.enable(this, holder, isReload = true) } } +@Deprecated( + "Use updateEffects on a dispatcher instead", + ReplaceWith("updateEffects()"), + DeprecationLevel.ERROR +) +fun Player.updateEffects() = + EntityDispatcher(this).updateEffects() + /** * Removes all elements from the given [other] list that are contained in this list. * diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt index 2db5d85ed..cc26d081c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt @@ -28,37 +28,33 @@ class ItemRefreshListener( @EventHandler fun onItemPickup(event: EntityPickupItemEvent) { - if (event.entity !is Player) { - return - } - val player = event.entity as Player - - player.refreshHolders() + EntityDispatcher(event.entity).refreshHolders() } @EventHandler fun onPlayerJoin(event: PlayerJoinEvent) { Bukkit.getServer().onlinePlayers.forEach { - it.refreshHolders() + EntityDispatcher(it).refreshHolders() } } @EventHandler fun onInventoryDrop(event: PlayerDropItemEvent) { - event.player.refreshHolders() + EntityDispatcher(event.player).refreshHolders() } @EventHandler fun onChangeSlot(event: PlayerItemHeldEvent) { - event.player.refreshHolders() + val dispatcher = EntityDispatcher(event.player) + dispatcher.refreshHolders() plugin.scheduler.run { - event.player.refreshHolders() + dispatcher.refreshHolders() } } @EventHandler fun onArmorChange(event: ArmorChangeEvent) { - event.player.refreshHolders() + EntityDispatcher(event.player).refreshHolders() } @EventHandler @@ -71,6 +67,6 @@ class ItemRefreshListener( inventoryClickTimeouts.put(player.uniqueId, Unit) - player.refreshHolders() + EntityDispatcher(player).refreshHolders() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index 1e9600991..ef1f8f122 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -30,6 +30,7 @@ import com.willfp.libreforge.levels.placeholder.ItemXPRequiredPlaceholder import com.willfp.libreforge.placeholders.CustomPlaceholders import com.willfp.libreforge.triggers.DispatchedTriggerFactory import org.bukkit.Bukkit +import org.bukkit.entity.LivingEntity import org.bukkit.event.Listener internal lateinit var plugin: LibreforgeSpigotPlugin @@ -115,9 +116,25 @@ class LibreforgeSpigotPlugin : EcoPlugin() { // Poll for changes plugin.scheduler.runTimer(20, 20) { for (player in Bukkit.getOnlinePlayers()) { - player.refreshHolders() + EntityDispatcher(player).refreshHolders() } } + + /* + Poll for changes in entities + Each world is offset by 3 ticks to prevent lag spikes + */ + var currentOffset = 30L + for (world in Bukkit.getWorlds()) { + plugin.scheduler.runTimer(currentOffset, 60) { + for (entity in world.entities) { + if (entity is LivingEntity) { + EntityDispatcher(entity).refreshHolders() + } + } + } + currentOffset += 3 + } } override fun loadListeners(): List { diff --git a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt index 3f7d5eae7..3c460f90a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt @@ -36,7 +36,5 @@ private class ProvidedHolderConfig( fun Config.applyHolder(providedHolder: ProvidedHolder, dispatcher: Dispatcher<*>): Config = ProvidedHolderConfig(this, providedHolder).apply { - dispatcher.ifType { - injectPlaceholders(*providedHolder.generatePlaceholders(it).mapToPlaceholders()) - } + injectPlaceholders(*providedHolder.generatePlaceholders(dispatcher).mapToPlaceholders()) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt index e601a8468..6cb806fd9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute @@ -37,13 +38,13 @@ object ConditionAboveHealthPercent : Condition("above_health_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDamageEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt index 05f8efa4e..d8812fca1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -32,7 +33,7 @@ object ConditionAboveHungerPercent : Condition("above_hunger_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: FoodLevelChangeEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt index 8529b5301..66e6a68d0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -32,6 +33,7 @@ object ConditionAboveXPLevel : Condition("above_xp_level") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerExpChangeEvent) { - event.player.updateEffects() + val dispatcher = EntityDispatcher(event.player) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt index 6f247c44a..30a5963b6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute @@ -37,13 +38,13 @@ object ConditionBelowHealthPercent : Condition("below_health_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDamageEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt index 8e001dfb1..d0c90ebf3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -32,7 +33,7 @@ object ConditionBelowHungerPercent : Condition("below_hunger_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: FoodLevelChangeEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt index 5b1a96624..06d602bb0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt @@ -6,6 +6,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -32,7 +33,7 @@ object ConditionBelowXPLevel : Condition("below_xp_level") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerExpChangeEvent) { - val player = event.player - player.updateEffects() + val dispatcher = EntityDispatcher(event.player) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt index 0d611cbb8..3d2505bfa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity @@ -27,7 +28,7 @@ object ConditionIsGliding : Condition("is_gliding") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityToggleGlideEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt index 7f0b4351d..00e0fd320 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -26,6 +27,7 @@ object ConditionIsSneaking : Condition("is_sneaking") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerToggleSneakEvent) { - event.player.updateEffects() + val dispatcher = EntityDispatcher(event.player) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt index 1c64e1711..2bdef26a3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -26,6 +27,7 @@ object ConditionIsSprinting : Condition("is_sprinting") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerToggleSprintEvent) { - event.player.updateEffects() + val dispatcher = EntityDispatcher(event.player) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt index a6c084afd..5f6b54617 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -23,8 +24,9 @@ object ConditionIsStorm: Condition("is_storm") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: WeatherChangeEvent) { - for (player in event.world.players) { - player.updateEffects() + for (entity in event.world.entities) { + val dispatcher = EntityDispatcher(entity) + dispatcher.updateEffects() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt index 7c1319194..71ca38cbf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity @@ -27,7 +28,7 @@ object ConditionIsSwimming : Condition("is_swimming") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityToggleSwimEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt index 9564f9192..72339f6e0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt @@ -5,6 +5,7 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity @@ -27,8 +28,6 @@ object ConditionOnFire : Condition("on_fire") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDamageEvent) { - val player = event.entity as? Player ?: return - if (event.cause != EntityDamageEvent.DamageCause.FIRE && event.cause != EntityDamageEvent.DamageCause.FIRE_TICK && event.cause != EntityDamageEvent.DamageCause.HOT_FLOOR @@ -37,6 +36,7 @@ object ConditionOnFire : Condition("on_fire") { return } - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt index 1ccd57c51..c9aa55dbc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity @@ -41,13 +42,13 @@ object ConditionRidingEntity : Condition>("riding_ent @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDismountEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityMountEvent) { - val player = event.entity as? Player ?: return - player.updateEffects() + val dispatcher = EntityDispatcher(event.entity) + dispatcher.updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt index a4f031a29..0ae208759 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt @@ -12,7 +12,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.registerDispatcherHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import java.util.UUID @@ -31,8 +31,8 @@ object EffectAddHolder : Effect("add_holder") { private val holders = listMap() init { - registerHolderProvider { - holders[it.uniqueId].map { h -> SimpleProvidedHolder(h) } + registerDispatcherHolderProvider { + holders[it.uuid].map { h -> SimpleProvidedHolder(h) } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt index 0c94be507..8cd36a55d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.Holder import com.willfp.libreforge.HolderTemplate import com.willfp.libreforge.SimpleProvidedHolder @@ -13,11 +14,10 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.registerDispatcherHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.Location -import org.bukkit.entity.Player import java.util.Objects import java.util.UUID import java.util.concurrent.TimeUnit @@ -41,9 +41,9 @@ object EffectAddHolderInRadius : Effect("add_holder_in_radius") .build>() init { - registerHolderProvider { player -> - nearbyCache.get(player.uniqueId) { _ -> - holders.filter { it.canApplyTo(player) } + registerDispatcherHolderProvider { dispatcher -> + nearbyCache.get(dispatcher.uuid) { _ -> + holders.filter { it.canApplyTo(dispatcher) } .map { SimpleProvidedHolder(it.holder) } } } @@ -97,16 +97,18 @@ object EffectAddHolderInRadius : Effect("add_holder_in_radius") val uuid: UUID, val applyToSelf: Boolean ) { - fun canApplyTo(player: Player): Boolean { - if (location.world != player.world) { + fun canApplyTo(dispatcher: Dispatcher<*>): Boolean { + val location = dispatcher.location ?: return false + + if (location.world != location.world) { return false } - if (player.uniqueId == uuid && !applyToSelf) { + if (dispatcher.uuid == uuid && !applyToSelf) { return false } - if (player.location.toVector().distanceSquared(location.toVector()) > radius * radius) { + if (location.toVector().distanceSquared(location.toVector()) > radius * radius) { return false } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt index 850726313..c44dd6b2d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt @@ -12,7 +12,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.registerDispatcherHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.Player @@ -32,7 +32,7 @@ object EffectAddHolderToVictim : Effect("add_holder_to_victim") private val holders = listMap() init { - registerHolderProvider { holders[it.uniqueId].map { h -> SimpleProvidedHolder(h) } } + registerDispatcherHolderProvider { holders[it.uuid].map { h -> SimpleProvidedHolder(h) } } } override fun onTrigger(config: Config, data: TriggerData, compileData: HolderTemplate): Boolean { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt index 499e44f5e..3e730e9e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt @@ -12,11 +12,10 @@ import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.registerDispatcherHolderProvider import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.Bukkit -import org.bukkit.entity.Player import java.util.Objects import java.util.UUID import java.util.concurrent.TimeUnit @@ -35,9 +34,9 @@ object EffectAddPermanentHolderInRadius : Effect("add_permanent_ .build>() init { - registerHolderProvider { player -> - nearbyCache.get(player.uniqueId) { _ -> - holders.filter { it.canApplyTo(player) } + registerDispatcherHolderProvider { dispatcher -> + nearbyCache.get(dispatcher.uuid) { _ -> + holders.filter { it.canApplyTo(dispatcher) } .map { SimpleProvidedHolder(it.holder) } } } @@ -90,18 +89,19 @@ object EffectAddPermanentHolderInRadius : Effect("add_permanent_ val owner: UUID, val applyToSelf: Boolean ) { - fun canApplyTo(player: Player): Boolean { + fun canApplyTo(dispatcher: Dispatcher<*>): Boolean { + val dispatcherLocation = dispatcher.location ?: return false val location = Bukkit.getPlayer(owner)?.location ?: return false - if (location.world != player.world) { + if (location.world != dispatcherLocation.world) { return false } - if (player.uniqueId == owner && !applyToSelf) { + if (dispatcher.uuid == owner && !applyToSelf) { return false } - if (player.location.toVector().distanceSquared(location.toVector()) > radius * radius) { + if (dispatcherLocation.toVector().distanceSquared(location.toVector()) > radius * radius) { return false } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt index e08758a9a..037578c30 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt @@ -1,12 +1,14 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter +import com.willfp.libreforge.updateEffects import com.willfp.libreforge.updateHolders import org.bukkit.Material @@ -35,7 +37,7 @@ object EffectConsumeHeldItem : Effect("consume_held_item") { player.inventory.setItemInMainHand(item) - player.updateHolders() + EntityDispatcher(player).updateHolders() return true } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt index 0e271d69d..315612821 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt @@ -8,6 +8,7 @@ import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player @@ -21,9 +22,8 @@ object ConditionHasMana : Condition("has_mana") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: ManaRegenerateEvent) { - val player = event.player - - player.updateEffects() + val dispatcher = EntityDispatcher(event.player) + dispatcher.updateEffects() } override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt index 49b438546..07fdbf822 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt @@ -59,15 +59,11 @@ abstract class Trigger( dispatcher: Dispatcher<*>, data: TriggerData, forceHolders: Collection? = null - ) { - if (dispatcher.isType()) { - val player = dispatcher.get()!! - val effects = forceHolders?.getProvidedActiveEffects(player) ?: player.providedActiveEffects - dispatchOnEffects(dispatcher, data, effects) - } else { - dispatchOnEffects(dispatcher, data, emptyList()) - } - } + ) = dispatchOnEffects( + dispatcher, + data, + forceHolders?.getProvidedActiveEffects(dispatcher) ?: dispatcher.providedActiveEffects + ) /** * Dispatch the trigger on a collection of [ProvidedEffectBlock]s. @@ -103,10 +99,8 @@ abstract class Trigger( val withHolder = data.copy(holder = holder) val dispatchWithHolder = DispatchedTrigger(dispatcher, this, withHolder).inheritPlaceholders(dispatch) - dispatcher.ifType { player -> - for (placeholder in holder.generatePlaceholders(player)) { - dispatchWithHolder.addPlaceholder(placeholder) - } + for (placeholder in holder.generatePlaceholders(dispatcher)) { + dispatchWithHolder.addPlaceholder(placeholder) } for (block in blocks) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Triggers.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Triggers.kt index bda78ded8..396cd0c30 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Triggers.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Triggers.kt @@ -37,6 +37,7 @@ import com.willfp.libreforge.triggers.impl.TriggerFillBucket import com.willfp.libreforge.triggers.impl.TriggerGainHunger import com.willfp.libreforge.triggers.impl.TriggerGainXp import com.willfp.libreforge.triggers.impl.TriggerGroupCustom +import com.willfp.libreforge.triggers.impl.TriggerGroupGlobalStatic import com.willfp.libreforge.triggers.impl.TriggerGroupStatic import com.willfp.libreforge.triggers.impl.TriggerHeadshot import com.willfp.libreforge.triggers.impl.TriggerHeal @@ -129,6 +130,7 @@ object Triggers : Registry() { init { register(TriggerGroupCustom) register(TriggerGroupStatic) + register(TriggerGroupGlobalStatic) register(TriggerAltClick) register(TriggerBite) register(TriggerBlockItemDrop) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt index 99844c969..d782d433e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderDisableEvent import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,12 +16,13 @@ object TriggerDisable : Trigger("disable") { @EventHandler(ignoreCancelled = true) fun handle(event: HolderDisableEvent) { - val player = event.player + val dispatcher = event.dispatcher this.dispatch( - EntityDispatcher(player), + dispatcher, TriggerData( - player = player, + player = dispatcher.get(), + victim = dispatcher.get(), event = event ), forceHolders = event.previousHolders diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt index a54594f48..e1df273bf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderEnableEvent import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.get import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,12 +16,13 @@ object TriggerEnable : Trigger("enable") { @EventHandler(ignoreCancelled = true) fun handle(event: HolderEnableEvent) { - val player = event.player + val dispatcher = event.dispatcher this.dispatch( - EntityDispatcher(player), + dispatcher, TriggerData( - player = player, + player = dispatcher.get(), + victim = dispatcher.get(), event = event ), forceHolders = event.newHolders diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt new file mode 100644 index 000000000..a2b1d65f0 --- /dev/null +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt @@ -0,0 +1,40 @@ +package com.willfp.libreforge.triggers.impl + +import com.willfp.libreforge.GlobalDispatcher +import com.willfp.libreforge.plugin +import com.willfp.libreforge.triggers.Trigger +import com.willfp.libreforge.triggers.TriggerData +import com.willfp.libreforge.triggers.TriggerGroup +import com.willfp.libreforge.triggers.TriggerParameter +import org.bukkit.Bukkit + +object TriggerGroupGlobalStatic : TriggerGroup("global_static") { + private val registry = mutableMapOf() + private var tick = 0 + + override fun create(value: String): Trigger? { + val interval = value.toIntOrNull() ?: return null + val trigger = TriggerGlobalStatic(interval) + registry[interval] = trigger + return trigger + } + + override fun postRegister() { + plugin.scheduler.runTimer(1, 1) { + tick++ + + for ((interval, trigger) in registry) { + if (tick % interval == 0) { + trigger.dispatch( + GlobalDispatcher, + TriggerData() + ) + } + } + } + } + + private class TriggerGlobalStatic(interval: Int) : Trigger("global_static_$interval") { + override val parameters = emptySet() + } +} diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt index e235d5eb3..591865f65 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt @@ -29,7 +29,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { @EventHandler(ignoreCancelled = true) fun onProjectileLaunch(event: ProjectileLaunchEvent) { - val shooter = event.entity.shooter as? Player ?: return + val shooter = event.entity.shooter as? LivingEntity ?: return val trident = event.entity if (trident !is Trident) { @@ -39,7 +39,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { trident.setMetadata( META_KEY, plugin.metadataValueFactory.create( - shooter.holders + EntityDispatcher(shooter).holders ) ) } From 06cb28733d145731766840cd092fafaef9facd96 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 15:42:58 +0000 Subject: [PATCH 07/11] Updated to 4.44.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 868676db3..7a07e4bdf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 4.43.1 +version = 4.44.0 kotlin.code.style = official \ No newline at end of file From acb3b33595b612b23281405df16adb53bae26d7c Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 16:02:38 +0000 Subject: [PATCH 08/11] Minor HolderProvider changes --- .../com/willfp/libreforge/HolderProvider.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 66890c2d6..abb01871b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.GlobalDispatcher.dispatcher import com.willfp.libreforge.effects.EffectBlock import org.bukkit.Bukkit @@ -128,6 +129,21 @@ fun registerDispatcherHolderProvider(provider: (Dispatcher<*>) -> Collection) = provider(dispatcher) }) +/** + * Register a new holder provider for a specific type of dispatcher. + */ +inline fun registerSpecificHolderProvider(crossinline provider: (Dispatcher) -> Collection) = + registerHolderProvider(object : HolderProvider { + override fun provide(dispatcher: Dispatcher<*>): Collection { + return if (dispatcher.isType()) { + @Suppress("UNCHECKED_CAST") + provider(dispatcher as Dispatcher) + } else { + emptyList() + } + } + }) + private val refreshFunctions = mutableListOf<(Dispatcher<*>) -> Unit>() /** @@ -179,8 +195,9 @@ fun registerPlaceholderProvider(provider: (ProvidedHolder, Dispatcher<*>) -> Col /** * Register a function to generate placeholders for a holder. */ -inline fun registerHolderPlaceholderProvider(crossinline provider: (T, Dispatcher<*>) -> Collection) { - registerPlaceholderProvider { holder, dispatcher -> +inline fun registerHolderPlaceholderProvider(crossinline provider: (T, Dispatcher<*>) -> Collection) { + registerPlaceholderProvider { provided, dispatcher -> + val holder = provided.holder if (holder is T) { provider(holder, dispatcher) } else { From 9cff7c469a1b45760080329ac735f29f36108750 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 21:15:01 +0000 Subject: [PATCH 09/11] Added Entity#toDispatcher and improved deprecation messages --- .../com/willfp/libreforge/Dispatcher.kt | 13 ++-- .../willfp/libreforge/EffectCollisionFixer.kt | 4 +- .../kotlin/com/willfp/libreforge/Holder.kt | 4 +- .../com/willfp/libreforge/HolderProvider.kt | 66 +++++++++++-------- .../com/willfp/libreforge/HolderUpdates.kt | 12 ++-- .../libreforge/LibreforgeSpigotPlugin.kt | 4 +- .../willfp/libreforge/ProvidedHolderConfig.kt | 1 - .../willfp/libreforge/conditions/Condition.kt | 6 +- .../libreforge/conditions/ConditionBlock.kt | 10 +-- .../libreforge/conditions/ConditionList.kt | 18 ++--- .../conditions/impl/ConditionAboveBalance.kt | 2 +- .../impl/ConditionAboveGlobalPoints.kt | 4 +- .../impl/ConditionAboveHealthPercent.kt | 10 ++- .../impl/ConditionAboveHungerPercent.kt | 7 +- .../conditions/impl/ConditionAbovePoints.kt | 4 +- .../conditions/impl/ConditionAboveXPLevel.kt | 7 +- .../conditions/impl/ConditionAboveY.kt | 2 +- .../conditions/impl/ConditionAnyOf.kt | 2 +- .../conditions/impl/ConditionAtLeastOf.kt | 2 +- .../conditions/impl/ConditionBelowBalance.kt | 2 +- .../impl/ConditionBelowGlobalPoints.kt | 4 +- .../impl/ConditionBelowHealthPercent.kt | 10 ++- .../impl/ConditionBelowHungerPercent.kt | 7 +- .../conditions/impl/ConditionBelowPoints.kt | 4 +- .../conditions/impl/ConditionBelowXPLevel.kt | 7 +- .../conditions/impl/ConditionBelowY.kt | 2 +- .../impl/ConditionCanAffordPrice.kt | 4 +- .../impl/ConditionGlobalPointsEqual.kt | 4 +- .../conditions/impl/ConditionHasItemData.kt | 2 +- .../conditions/impl/ConditionHasPermission.kt | 2 +- .../impl/ConditionHasPotionEffect.kt | 2 +- .../conditions/impl/ConditionInAir.kt | 2 +- .../conditions/impl/ConditionInBiome.kt | 2 +- .../conditions/impl/ConditionInBlock.kt | 2 +- .../conditions/impl/ConditionInMainhand.kt | 1 - .../conditions/impl/ConditionInWater.kt | 2 +- .../conditions/impl/ConditionInWorld.kt | 2 +- .../impl/ConditionIsExpressionTrue.kt | 2 +- .../conditions/impl/ConditionIsFalling.kt | 2 +- .../conditions/impl/ConditionIsFlying.kt | 2 +- .../conditions/impl/ConditionIsFrozen.kt | 2 +- .../conditions/impl/ConditionIsGliding.kt | 8 +-- .../conditions/impl/ConditionIsNight.kt | 2 +- .../conditions/impl/ConditionIsOp.kt | 2 +- .../conditions/impl/ConditionIsSneaking.kt | 7 +- .../conditions/impl/ConditionIsSprinting.kt | 7 +- .../conditions/impl/ConditionIsStorm.kt | 7 +- .../conditions/impl/ConditionIsSwimming.kt | 8 +-- .../impl/ConditionItemDataEquals.kt | 4 +- .../impl/ConditionItemLevelAbove.kt | 4 +- .../impl/ConditionItemLevelBelow.kt | 4 +- .../impl/ConditionItemLevelEquals.kt | 4 +- .../impl/ConditionItemPointsAbove.kt | 4 +- .../impl/ConditionItemPointsBelow.kt | 4 +- .../impl/ConditionItemPointsEqual.kt | 4 +- .../conditions/impl/ConditionNearEntity.kt | 2 +- .../conditions/impl/ConditionOnFire.kt | 8 +-- .../conditions/impl/ConditionOnGround.kt | 2 +- .../impl/ConditionPlaceholderContains.kt | 2 +- .../impl/ConditionPlaceholderEquals.kt | 2 +- .../impl/ConditionPlaceholderGreaterThan.kt | 2 +- .../impl/ConditionPlaceholderLessThan.kt | 2 +- .../conditions/impl/ConditionPointsEqual.kt | 4 +- .../conditions/impl/ConditionRidingEntity.kt | 11 ++-- .../impl/ConditionStandingOnBlock.kt | 2 +- .../conditions/impl/ConditionWearingBoots.kt | 1 - .../impl/ConditionWearingChestplate.kt | 1 - .../conditions/impl/ConditionWearingHelmet.kt | 1 - .../impl/ConditionWearingLeggings.kt | 1 - .../impl/ConditionWithinRadiusOf.kt | 2 +- .../conditions/templates/ItemCondition.kt | 4 +- .../libreforge/counters/bind/BoundCounter.kt | 2 +- .../com/willfp/libreforge/effects/Chain.kt | 10 +-- .../willfp/libreforge/effects/ChainElement.kt | 12 ++-- .../com/willfp/libreforge/effects/Effect.kt | 18 ++--- .../willfp/libreforge/effects/EffectBlock.kt | 12 ++-- .../willfp/libreforge/effects/RichChain.kt | 5 -- .../effects/arguments/EffectArgument.kt | 1 - .../arguments/custom/CustomEffectArguments.kt | 2 - .../arguments/impl/ArgumentChainArgs.kt | 2 +- .../arguments/impl/ArgumentCooldown.kt | 2 +- .../effects/arguments/impl/ArgumentCost.kt | 2 +- .../effects/arguments/impl/ArgumentEvery.kt | 2 +- .../arguments/impl/ArgumentPointCost.kt | 2 +- .../effects/arguments/impl/ArgumentPrice.kt | 2 +- .../effects/events/EffectDisableEvent.kt | 4 +- .../effects/events/EffectEnableEvent.kt | 4 +- .../libreforge/effects/impl/EffectAOE.kt | 4 +- .../effects/impl/EffectAOEBlocks.kt | 4 +- .../effects/impl/EffectAddHolder.kt | 4 +- .../effects/impl/EffectAddHolderInRadius.kt | 4 +- .../effects/impl/EffectAddHolderToVictim.kt | 4 +- .../impl/EffectAddPermanentHolderInRadius.kt | 6 +- .../effects/impl/EffectAddPoints.kt | 4 +- .../effects/impl/EffectAllPlayers.kt | 4 +- .../libreforge/effects/impl/EffectBleed.kt | 1 - .../effects/impl/EffectBlockCommands.kt | 2 +- .../effects/impl/EffectBreakBlock.kt | 3 - .../effects/impl/EffectBrewTimeMultiplier.kt | 4 +- .../effects/impl/EffectCloseInventory.kt | 1 - .../effects/impl/EffectConsumeHeldItem.kt | 5 +- .../effects/impl/EffectCreateBossBar.kt | 5 -- .../effects/impl/EffectDamageItem.kt | 1 - .../impl/EffectDontConsumeLapisChance.kt | 4 +- .../effects/impl/EffectDontConsumeXpChance.kt | 4 +- .../effects/impl/EffectFeatherStep.kt | 2 +- .../libreforge/effects/impl/EffectFlight.kt | 2 +- .../effects/impl/EffectFoodMultiplier.kt | 4 +- .../effects/impl/EffectGiveSaturation.kt | 1 - .../effects/impl/EffectGlowNearbyBlocks.kt | 1 - .../effects/impl/EffectHungerMultiplier.kt | 6 +- .../effects/impl/EffectKeepInventory.kt | 2 +- .../libreforge/effects/impl/EffectMineVein.kt | 1 - .../effects/impl/EffectParticleLine.kt | 1 - .../impl/EffectPermanentPotionEffect.kt | 4 +- .../impl/EffectPotionDurationMultiplier.kt | 6 +- .../effects/impl/EffectRandomPlayer.kt | 4 +- .../effects/impl/EffectRapidBows.kt | 4 +- .../effects/impl/EffectReelSpeedMultiplier.kt | 4 +- .../effects/impl/EffectRegenMultiplier.kt | 4 +- .../effects/impl/EffectRemoveBossBar.kt | 1 - .../effects/impl/EffectRemoveItemData.kt | 4 -- .../effects/impl/EffectReplaceNear.kt | 1 - .../effects/impl/EffectReplantCrops.kt | 2 +- .../libreforge/effects/impl/EffectRunChain.kt | 4 +- .../effects/impl/EffectRunChainInline.kt | 4 +- .../effects/impl/EffectRunCommand.kt | 1 - .../effects/impl/EffectRunPlayerCommand.kt | 1 - .../effects/impl/EffectSellMultiplier.kt | 4 +- .../effects/impl/EffectSetArmorTrim.kt | 2 - .../effects/impl/EffectSetItemData.kt | 3 - .../libreforge/effects/impl/EffectShoot.kt | 1 - .../libreforge/effects/impl/EffectSwarm.kt | 4 -- .../effects/impl/EffectTelekinesis.kt | 2 +- .../effects/impl/EffectTriggerNestedChain.kt | 4 +- .../impl/EffectVictimSpeedMultiplier.kt | 1 - .../effects/impl/EffectXpMultiplier.kt | 4 +- .../effects/impl/aoe/impl/AOEShapeCircle.kt | 1 - .../effects/impl/aoe/impl/AOEShapeCone.kt | 1 - .../impl/aoe/impl/AOEShapeOffsetCircle.kt | 1 - .../impl/aoe/impl/AOEShapeScanInFront.kt | 1 - .../effects/impl/bossbar/BossBars.kt | 5 -- .../effects/templates/AttributeEffect.kt | 4 +- .../templates/ChanceMultiplierEffect.kt | 10 +-- .../effects/templates/DamageItemEffect.kt | 1 - .../templates/MultiMultiplierEffect.kt | 10 +-- .../effects/templates/MultiplierEffect.kt | 10 +-- .../com/willfp/libreforge/filters/Filters.kt | 2 +- .../filters/impl/FilterIsBehindVictim.kt | 2 - .../filters/impl/FilterIsPassive.kt | 4 -- .../impl/FilterItemDurabilityAbovePercent.kt | 2 - .../impl/FilterItemDurabilityBelowPercent.kt | 2 - .../filters/impl/FilterValueAbove.kt | 1 - .../filters/impl/FilterVictimConditions.kt | 4 +- .../aureliumskills/impl/ArgumentManaCost.kt | 2 +- .../aureliumskills/impl/ConditionHasMana.kt | 7 +- .../aureliumskills/impl/EffectAddStat.kt | 4 +- .../impl/EffectSkillXpMultiplier.kt | 4 +- .../citizens/impl/TriggerLeftClickNPC.kt | 4 +- .../citizens/impl/TriggerRightClickNPC.kt | 4 +- .../jobs/impl/EffectJobsMoneyMultiplier.kt | 4 +- .../jobs/impl/EffectJobsXpMultiplier.kt | 4 +- .../jobs/impl/TriggerJobsLevelUp.kt | 4 +- .../mcmmo/impl/EffectMcMMOXpMultiplier.kt | 4 +- .../paper/impl/ConditionInBubble.kt | 2 +- .../paper/impl/ConditionInLava.kt | 2 +- .../paper/impl/ConditionInRain.kt | 2 +- .../paper/impl/EffectDropPickupItem.kt | 4 +- .../paper/impl/EffectElytraBoostSaveChance.kt | 4 +- .../paper/impl/TriggerBeaconEffect.kt | 4 +- .../paper/impl/TriggerElytraBoost.kt | 4 +- .../integrations/paper/impl/TriggerSwing.kt | 4 +- .../paper/impl/TriggerVillagerTrade.kt | 4 +- .../scyther/impl/TriggerScytherAutoCollect.kt | 4 +- .../scyther/impl/TriggerScytherAutoSell.kt | 4 +- .../tmmobcoins/TMMobcoinsIntegration.kt | 2 - .../impl/EffectMobCoinsMultiplier.kt | 4 +- .../vault/impl/EffectGivePermission.kt | 2 +- .../worldguard/impl/ConditionInRegion.kt | 2 +- .../worldguard/impl/TriggerEnterRegion.kt | 4 +- .../worldguard/impl/TriggerLeaveRegion.kt | 4 +- .../com/willfp/libreforge/levels/LevelType.kt | 4 +- .../mutators/impl/MutatorLocationToBlock.kt | 1 - .../mutators/impl/MutatorLocationToPlayer.kt | 1 - .../mutators/impl/MutatorVictimToOwner.kt | 2 - .../impl/ConditionalCustomPlaceholder.kt | 5 +- .../com/willfp/libreforge/slot/SlotTypes.kt | 6 +- .../libreforge/triggers/DispatchedTrigger.kt | 8 +-- .../triggers/DispatchedTriggerFactory.kt | 4 +- .../com/willfp/libreforge/triggers/Trigger.kt | 9 +-- .../willfp/libreforge/triggers/TriggerData.kt | 6 +- .../triggers/event/TriggerDispatchEvent.kt | 4 +- .../triggers/impl/TriggerAltClick.kt | 4 +- .../libreforge/triggers/impl/TriggerBite.kt | 4 +- .../triggers/impl/TriggerBlockItemDrop.kt | 4 +- .../triggers/impl/TriggerBowAttack.kt | 4 +- .../libreforge/triggers/impl/TriggerBreed.kt | 4 +- .../libreforge/triggers/impl/TriggerBrew.kt | 4 +- .../triggers/impl/TriggerBrewIngredient.kt | 4 +- .../triggers/impl/TriggerCastRod.kt | 4 +- .../triggers/impl/TriggerCatchEntity.kt | 3 +- .../triggers/impl/TriggerCatchFish.kt | 4 +- .../triggers/impl/TriggerCatchFishFail.kt | 4 +- .../triggers/impl/TriggerChangeArmor.kt | 4 +- .../triggers/impl/TriggerChangeChunk.kt | 4 +- .../triggers/impl/TriggerChangeWorld.kt | 4 +- .../triggers/impl/TriggerClickBlock.kt | 4 +- .../triggers/impl/TriggerClickEntity.kt | 4 +- .../triggers/impl/TriggerConsume.kt | 4 +- .../libreforge/triggers/impl/TriggerCraft.kt | 4 +- .../triggers/impl/TriggerDamageItem.kt | 4 +- .../libreforge/triggers/impl/TriggerDeath.kt | 4 +- .../triggers/impl/TriggerDeployElytra.kt | 4 +- .../triggers/impl/TriggerDisable.kt | 1 - .../libreforge/triggers/impl/TriggerDrink.kt | 4 +- .../triggers/impl/TriggerDropItem.kt | 4 +- .../triggers/impl/TriggerEmptyBucket.kt | 4 +- .../libreforge/triggers/impl/TriggerEnable.kt | 1 - .../triggers/impl/TriggerEnchantItem.kt | 4 +- .../triggers/impl/TriggerEnterBed.kt | 4 +- .../triggers/impl/TriggerEntityItemDrop.kt | 4 +- .../triggers/impl/TriggerEntityTarget.kt | 4 +- .../triggers/impl/TriggerFallDamage.kt | 4 +- .../triggers/impl/TriggerFillBucket.kt | 4 +- .../triggers/impl/TriggerGainHunger.kt | 4 +- .../libreforge/triggers/impl/TriggerGainXp.kt | 4 +- .../triggers/impl/TriggerGroupCustom.kt | 4 +- .../triggers/impl/TriggerGroupGlobalStatic.kt | 1 - .../triggers/impl/TriggerGroupStatic.kt | 4 +- .../triggers/impl/TriggerHeadshot.kt | 4 +- .../libreforge/triggers/impl/TriggerHeal.kt | 4 +- .../triggers/impl/TriggerHoldItem.kt | 4 +- .../triggers/impl/TriggerHookInGround.kt | 4 +- .../triggers/impl/TriggerItemBreak.kt | 4 +- .../libreforge/triggers/impl/TriggerJoin.kt | 4 +- .../libreforge/triggers/impl/TriggerJump.kt | 4 +- .../libreforge/triggers/impl/TriggerKill.kt | 6 +- .../triggers/impl/TriggerLeashEntity.kt | 4 +- .../libreforge/triggers/impl/TriggerLeave.kt | 4 +- .../triggers/impl/TriggerLeaveBed.kt | 4 +- .../triggers/impl/TriggerLevelUpItem.kt | 4 +- .../triggers/impl/TriggerLevelUpXp.kt | 4 +- .../triggers/impl/TriggerLoseHunger.kt | 4 +- .../triggers/impl/TriggerLosePotionEffect.kt | 4 +- .../triggers/impl/TriggerMeleeAttack.kt | 4 +- .../triggers/impl/TriggerMineBlock.kt | 4 +- .../triggers/impl/TriggerMineBlockProgress.kt | 4 +- .../libreforge/triggers/impl/TriggerMove.kt | 4 +- .../triggers/impl/TriggerPickUpItem.kt | 4 +- .../triggers/impl/TriggerPlaceBlock.kt | 4 +- .../triggers/impl/TriggerPotionEffect.kt | 4 +- .../triggers/impl/TriggerProjectileHit.kt | 6 +- .../triggers/impl/TriggerProjectileLaunch.kt | 4 +- .../libreforge/triggers/impl/TriggerReelIn.kt | 4 +- .../triggers/impl/TriggerRespawn.kt | 4 +- .../triggers/impl/TriggerRunCommand.kt | 4 +- .../triggers/impl/TriggerSellItem.kt | 4 +- .../triggers/impl/TriggerSendMessage.kt | 4 +- .../triggers/impl/TriggerShearEntity.kt | 4 +- .../triggers/impl/TriggerShieldBlock.kt | 4 +- .../triggers/impl/TriggerShootBow.kt | 4 +- .../libreforge/triggers/impl/TriggerSmelt.kt | 4 +- .../triggers/impl/TriggerSwapHands.kt | 4 +- .../triggers/impl/TriggerTakeDamage.kt | 4 +- .../triggers/impl/TriggerTakeEntityDamage.kt | 4 +- .../triggers/impl/TriggerTameAnimal.kt | 4 +- .../triggers/impl/TriggerTeleport.kt | 4 +- .../triggers/impl/TriggerToggleFlight.kt | 4 +- .../triggers/impl/TriggerToggleSneak.kt | 4 +- .../triggers/impl/TriggerToggleSprint.kt | 4 +- .../triggers/impl/TriggerTridentAttack.kt | 8 +-- .../triggers/impl/TriggerWinRaid.kt | 4 +- .../impl/TriggerPlaceholderPlayer.kt | 1 - 273 files changed, 518 insertions(+), 607 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt index 1f288781f..c81e15a3c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt @@ -1,13 +1,12 @@ package com.willfp.libreforge -import io.papermc.paper.math.Position.block import org.bukkit.Location import org.bukkit.entity.Entity -import org.bukkit.entity.Player import java.util.UUID /** - * A dispatcher represents the object that dispatched a trigger (e.g. a player). + * A dispatcher represents an object that can execute effects, hold holders, + * and be used in conditions, for example a player, entity, block, or server. */ interface Dispatcher { /** @@ -51,7 +50,8 @@ inline fun Dispatcher<*>.ifType(block: (T) -> Unit) { /** * A dispatcher for an entity. */ -class EntityDispatcher( +@JvmInline +value class EntityDispatcher( override val dispatcher: Entity ) : Dispatcher { override val uuid @@ -61,6 +61,11 @@ class EntityDispatcher( get() = dispatcher.location } +/** + * Convert an entity to a dispatcher. + */ +fun Entity.toDispatcher(): Dispatcher = EntityDispatcher(this) + /** * A dispatcher for the global scope. */ diff --git a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt index 2e797dc3b..a79695e50 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/EffectCollisionFixer.kt @@ -13,7 +13,7 @@ object EffectCollisionFixer : Listener { @EventHandler(priority = EventPriority.LOWEST) fun clearOnQuit(event: PlayerQuitEvent) { val player = event.player - val dispatcher = EntityDispatcher(player) + val dispatcher = player.toDispatcher() for ((holder, effects) in dispatcher.providedActiveEffects) { for (effect in effects) { @@ -31,7 +31,7 @@ object EffectCollisionFixer : Listener { @EventHandler(priority = EventPriority.LOWEST) fun scanOnJoin(event: PlayerJoinEvent) { val player = event.player - val dispatcher = EntityDispatcher(player) + val dispatcher = player.toDispatcher() // Extra fix for pre-4.2.3 player.fixAttributes() diff --git a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt index d6907d255..7ffbc4af8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Holder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Holder.kt @@ -101,7 +101,7 @@ interface ProvidedHolder { * Get not met lines for a [player]. */ fun getNotMetLines(player: Player): List = - getNotMetLines(EntityDispatcher(player)) + getNotMetLines(player.toDispatcher()) /** * Get if the holder is showing any not met lines for a [dispatcher], or if any @@ -117,7 +117,7 @@ interface ProvidedHolder { * conditions are not met and have showNotMet set to true (e.g. for Enchantment Strikethrough). */ fun isShowingAnyNotMet(player: Player): Boolean = - isShowingAnyNotMet(EntityDispatcher(player)) + isShowingAnyNotMet(player.toDispatcher()) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index abb01871b..46d0b0338 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -2,7 +2,6 @@ package com.willfp.libreforge import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.map.listMap -import com.willfp.libreforge.EmptyProvidedHolder.holder import com.willfp.libreforge.GlobalDispatcher.dispatcher import com.willfp.libreforge.effects.EffectBlock import org.bukkit.Bukkit @@ -106,8 +105,8 @@ fun registerHolderProvider(provider: HolderProvider) = providers.add(provider) * Register a new holder provider. */ @Deprecated( - "Use registerHolderProvider instead", - ReplaceWith("registerHolderProvider(provider)"), + "Use registerSpecificHolderProvider instead", + ReplaceWith("registerSpecificHolderProvider(provider)"), DeprecationLevel.ERROR ) fun registerHolderProvider(provider: (Player) -> Collection) = @@ -122,9 +121,9 @@ fun registerHolderProvider(provider: (Player) -> Collection) = }) /** - * Register a new holder provider. + * Register a new holder provider for all possible dispatchers. */ -fun registerDispatcherHolderProvider(provider: (Dispatcher<*>) -> Collection) = +fun registerGenericHolderProvider(provider: (Dispatcher<*>) -> Collection) = registerHolderProvider(object : HolderProvider { override fun provide(dispatcher: Dispatcher<*>) = provider(dispatcher) }) @@ -132,12 +131,11 @@ fun registerDispatcherHolderProvider(provider: (Dispatcher<*>) -> Collection registerSpecificHolderProvider(crossinline provider: (Dispatcher) -> Collection) = +inline fun registerSpecificHolderProvider(crossinline provider: (T) -> Collection) = registerHolderProvider(object : HolderProvider { override fun provide(dispatcher: Dispatcher<*>): Collection { return if (dispatcher.isType()) { - @Suppress("UNCHECKED_CAST") - provider(dispatcher as Dispatcher) + provider(dispatcher.get()!!) } else { emptyList() } @@ -177,11 +175,11 @@ fun Dispatcher<*>.refreshHolders() { @Deprecated( "Use refreshHolders on a dispatcher instead", - ReplaceWith("refreshHolders()"), + ReplaceWith("toDispatcher().refreshHolders()"), DeprecationLevel.ERROR ) fun Player.refreshHolders() = - EntityDispatcher(this).refreshHolders() + this.toDispatcher().refreshHolders() private val holderPlaceholderProviders = mutableListOf<(ProvidedHolder, Dispatcher<*>) -> Collection>() @@ -193,7 +191,7 @@ fun registerPlaceholderProvider(provider: (ProvidedHolder, Dispatcher<*>) -> Col } /** - * Register a function to generate placeholders for a holder. + * Register a function to generate placeholders for a holder for any dispatcher. */ inline fun registerHolderPlaceholderProvider(crossinline provider: (T, Dispatcher<*>) -> Collection) { registerPlaceholderProvider { provided, dispatcher -> @@ -206,6 +204,20 @@ inline fun registerHolderPlaceholderProvider(crossinline pro } } +/** + * Register a function to generate placeholders for a holder for a specific dispatcher. + */ +inline fun registerSpecificHolderPlaceholderProvider(crossinline provider: (T, R) -> Collection) { + registerPlaceholderProvider { provided, dispatcher -> + val holder = provided.holder + if (holder is T && dispatcher.isType()) { + provider(holder, dispatcher.get()!!) + } else { + emptyList() + } + } +} + /** * Generate placeholders for a holder. */ @@ -260,11 +272,11 @@ val Dispatcher<*>.holders: Collection @Deprecated( "Use a dispatcher instead of a player", - ReplaceWith("holders"), + ReplaceWith("toDispatcher().holders"), DeprecationLevel.ERROR ) val Player.holders: Collection - get() = EntityDispatcher(this).holders + get() = this.toDispatcher().holders /** * Invalidate holder cache to force rescan. @@ -275,11 +287,11 @@ fun Dispatcher<*>.updateHolders() { @Deprecated( "Use updateHolders on a dispatcher instead", - ReplaceWith("updateHolders()"), + ReplaceWith("toDispatcher().updateHolders()"), DeprecationLevel.ERROR ) fun Player.updateHolders() = - EntityDispatcher(this).updateHolders() + this.toDispatcher().updateHolders() fun Dispatcher<*>.purgePreviousHolders() { previousHolders.remove(this.uuid) @@ -322,11 +334,11 @@ fun Collection.getProvidedActiveEffects(dispatcher: Dispatcher<* @Deprecated( "Use getProvidedActiveEffects on a dispatcher instead", - ReplaceWith("getProvidedActiveEffects(dispatcher)"), + ReplaceWith("getProvidedActiveEffects(player.toDispatcher())"), DeprecationLevel.ERROR ) fun Collection.getProvidedActiveEffects(player: Player): List = - this.getProvidedActiveEffects(EntityDispatcher(player)) + this.getProvidedActiveEffects(player.toDispatcher()) /** * Get active effects for a [dispatcher]. @@ -336,11 +348,11 @@ fun ProvidedHolder.getActiveEffects(dispatcher: Dispatcher<*>) = @Deprecated( "Use getActiveEffects on a dispatcher instead", - ReplaceWith("getActiveEffects(dispatcher)"), + ReplaceWith("getActiveEffects(player.toDispatcher())"), DeprecationLevel.ERROR ) fun ProvidedHolder.getActiveEffects(player: Player) = - getActiveEffects(EntityDispatcher(player)) + getActiveEffects(player.toDispatcher()) /** * Recalculate active effects. @@ -350,11 +362,11 @@ fun Dispatcher<*>.calculateActiveEffects() = @Deprecated( "Use calculateActiveEffects on a dispatcher instead", - ReplaceWith("calculateActiveEffects()"), + ReplaceWith("toDispatcher().calculateActiveEffects()"), DeprecationLevel.ERROR ) fun Player.calculateActiveEffects() = - EntityDispatcher(this).calculateActiveEffects() + this.toDispatcher().calculateActiveEffects() /** * The active effects. @@ -364,11 +376,11 @@ val Dispatcher<*>.activeEffects: List @Deprecated( "Use activeEffects on a dispatcher instead", - ReplaceWith("activeEffects"), + ReplaceWith("toDispatcher().activeEffects"), DeprecationLevel.ERROR ) val Player.activeEffects: List - get() = EntityDispatcher(this).activeEffects + get() = this.toDispatcher().activeEffects /** * The active effects mapped to the holder that provided them. @@ -378,11 +390,11 @@ val Dispatcher<*>.providedActiveEffects: List @Deprecated( "Use providedActiveEffects on a dispatcher instead", - ReplaceWith("providedActiveEffects"), + ReplaceWith("toDispatcher().providedActiveEffects"), DeprecationLevel.ERROR ) val Player.providedActiveEffects: List - get() = EntityDispatcher(this).providedActiveEffects + get() = this.toDispatcher().providedActiveEffects /** * Update the active effects. @@ -425,11 +437,11 @@ fun Dispatcher<*>.updateEffects() { @Deprecated( "Use updateEffects on a dispatcher instead", - ReplaceWith("updateEffects()"), + ReplaceWith("toDispatcher().updateEffects()"), DeprecationLevel.ERROR ) fun Player.updateEffects() = - EntityDispatcher(this).updateEffects() + this.toDispatcher().updateEffects() /** * Removes all elements from the given [other] list that are contained in this list. diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt index cc26d081c..edcba7056 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderUpdates.kt @@ -28,24 +28,24 @@ class ItemRefreshListener( @EventHandler fun onItemPickup(event: EntityPickupItemEvent) { - EntityDispatcher(event.entity).refreshHolders() + event.entity.toDispatcher().refreshHolders() } @EventHandler fun onPlayerJoin(event: PlayerJoinEvent) { Bukkit.getServer().onlinePlayers.forEach { - EntityDispatcher(it).refreshHolders() + it.toDispatcher().refreshHolders() } } @EventHandler fun onInventoryDrop(event: PlayerDropItemEvent) { - EntityDispatcher(event.player).refreshHolders() + event.player.toDispatcher().refreshHolders() } @EventHandler fun onChangeSlot(event: PlayerItemHeldEvent) { - val dispatcher = EntityDispatcher(event.player) + val dispatcher = event.player.toDispatcher() dispatcher.refreshHolders() plugin.scheduler.run { dispatcher.refreshHolders() @@ -54,7 +54,7 @@ class ItemRefreshListener( @EventHandler fun onArmorChange(event: ArmorChangeEvent) { - EntityDispatcher(event.player).refreshHolders() + event.player.toDispatcher().refreshHolders() } @EventHandler @@ -67,6 +67,6 @@ class ItemRefreshListener( inventoryClickTimeouts.put(player.uniqueId, Unit) - EntityDispatcher(player).refreshHolders() + player.toDispatcher().refreshHolders() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index ef1f8f122..b86d768e5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -116,7 +116,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() { // Poll for changes plugin.scheduler.runTimer(20, 20) { for (player in Bukkit.getOnlinePlayers()) { - EntityDispatcher(player).refreshHolders() + player.toDispatcher().refreshHolders() } } @@ -129,7 +129,7 @@ class LibreforgeSpigotPlugin : EcoPlugin() { plugin.scheduler.runTimer(currentOffset, 60) { for (entity in world.entities) { if (entity is LivingEntity) { - EntityDispatcher(entity).refreshHolders() + entity.toDispatcher().refreshHolders() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt index 3c460f90a..bb421bc90 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/ProvidedHolderConfig.kt @@ -5,7 +5,6 @@ import com.willfp.eco.core.placeholder.context.PlaceholderContext import com.willfp.eco.core.placeholder.context.copy import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.formatEco -import org.bukkit.entity.Player /** * A [config] that uses a provided [holder] as a source of placeholders. diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt index ae5ecc534..37c8fb98e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/Condition.kt @@ -2,9 +2,9 @@ package com.willfp.libreforge.conditions import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.Compilable +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import org.bukkit.entity.Player import org.bukkit.event.Listener @@ -49,7 +49,7 @@ abstract class Condition( */ @Deprecated( "Use isMet(dispatcher, config, holder, compileData) instead.", - ReplaceWith("true") + ReplaceWith("isMet(player.toDispatcher(), config, holder, compileData)"), ) open fun isMet( player: Player, @@ -64,7 +64,7 @@ abstract class Condition( */ @Deprecated( "Use isMet(dispatcher, config, holder, compileData) instead.", - ReplaceWith("true") + ReplaceWith("isMet(player.toDispatcher(), config, holder, compileData)"), ) open fun isMet( player: Player, diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt index 36d82c3fb..68dd3c05f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionBlock.kt @@ -3,13 +3,13 @@ package com.willfp.libreforge.conditions import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.Compiled +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.applyHolder import com.willfp.libreforge.effects.Chain -import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.plugin +import com.willfp.libreforge.toDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID @@ -85,9 +85,9 @@ class ConditionBlock internal constructor( @Deprecated( "Use isMet(dispatcher, holder) instead", - ReplaceWith("isMet(dispatcher, holder)"), + ReplaceWith("isMet(player.toDispatcher(), holder)"), DeprecationLevel.ERROR ) fun isMet(player: Player, holder: ProvidedHolder): Boolean = - isMet(EntityDispatcher(player), holder) + isMet(player.toDispatcher(), holder) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt index fb321461a..d489be729 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/ConditionList.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions import com.willfp.eco.util.formatEco import com.willfp.libreforge.DelegatedList -import com.willfp.libreforge.ProvidedHolder -import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher +import com.willfp.libreforge.triggers.DispatchedTrigger import org.bukkit.entity.Player /** @@ -53,30 +53,30 @@ class ConditionList( @Deprecated( "Use areMet(dispatcher, holder) instead.", - ReplaceWith("areMet(dispatcher, holder)"), + ReplaceWith("areMet(player.toDispatcher(), holder)"), DeprecationLevel.ERROR ) fun areMet(player: Player, holder: ProvidedHolder): Boolean = - areMet(EntityDispatcher(player), holder) + areMet(player.toDispatcher(), holder) /** * Get if any conditions are not met and should be shown. */ @Deprecated( "Use isShowingAnyNotMet(dispatcher, holder) instead.", - ReplaceWith("isShowingAnyNotMet(dispatcher, holder)"), + ReplaceWith("isShowingAnyNotMet(player.toDispatcher(), holder)"), DeprecationLevel.ERROR ) fun isShowingAnyNotMet(player: Player, holder: ProvidedHolder): Boolean = - isShowingAnyNotMet(EntityDispatcher(player), holder) + isShowingAnyNotMet(player.toDispatcher(), holder) @Deprecated( "Use getNotMetLines(dispatcher, holder) instead.", - ReplaceWith("getNotMetLines(dispatcher, holder)"), + ReplaceWith("getNotMetLines(player.toDispatcher(), holder)"), DeprecationLevel.ERROR ) fun getNotMetLines(player: Player, holder: ProvidedHolder): List = - getNotMetLines(EntityDispatcher(player), holder) + getNotMetLines(player.toDispatcher(), holder) } /** diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt index e2576d65e..ff515ec94 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveBalance.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.economy.EconomyManager +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt index 4ca7cc150..1046cd8ad 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveGlobalPoints.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.globalPoints import org.bukkit.entity.Player object ConditionAboveGlobalPoints : Condition("above_global_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt index 6cb806fd9..7417ae68a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHealthPercent.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute import org.bukkit.entity.LivingEntity @@ -38,13 +38,11 @@ object ConditionAboveHealthPercent : Condition("above_health_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDamageEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt index d8812fca1..39852f974 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveHungerPercent.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -33,7 +33,6 @@ object ConditionAboveHungerPercent : Condition("above_hunger_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: FoodLevelChangeEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt index 60b0eea2d..4a94b905e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAbovePoints.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.points import org.bukkit.entity.Player object ConditionAbovePoints : Condition("above_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt index 66e6a68d0..6d182e762 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveXPLevel.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -33,7 +33,6 @@ object ConditionAboveXPLevel : Condition("above_xp_level") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerExpChangeEvent) { - val dispatcher = EntityDispatcher(event.player) - dispatcher.updateEffects() + event.player.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt index 92a15479a..a32bff1dd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAboveY.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get object ConditionAboveY : Condition("above_y") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt index f7a0dbab3..99f79d37d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAnyOf.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions -import com.willfp.libreforge.Dispatcher object ConditionAnyOf : Condition("any_of") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt index ee867cc00..858f9b513 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionAtLeastOf.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt index 9c88cee8f..94195704b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowBalance.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.economy.EconomyManager +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt index ecc703a58..7229998fe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowGlobalPoints.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.globalPoints import org.bukkit.entity.Player object ConditionBelowGlobalPoints : Condition("below_global_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt index 30a5963b6..77eff326b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHealthPercent.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.attribute.Attribute import org.bukkit.entity.LivingEntity @@ -38,13 +38,11 @@ object ConditionBelowHealthPercent : Condition("below_health_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDamageEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt index d0c90ebf3..0a9c078f1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowHungerPercent.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -33,7 +33,6 @@ object ConditionBelowHungerPercent : Condition("below_hunger_perc @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: FoodLevelChangeEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt index 986a80c33..3362d434d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowPoints.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.points import org.bukkit.entity.Player object ConditionBelowPoints : Condition("below_points") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt index 06d602bb0..7bbe4ba7c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowXPLevel.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -33,7 +33,6 @@ object ConditionBelowXPLevel : Condition("below_xp_level") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerExpChangeEvent) { - val dispatcher = EntityDispatcher(event.player) - dispatcher.updateEffects() + event.player.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt index 4d33ac0da..c269c97d3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionBelowY.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get object ConditionBelowY : Condition("below_y") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt index 5ecaa7bbe..72e8193d8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionCanAffordPrice.kt @@ -3,13 +3,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.price.Price import com.willfp.eco.core.price.Prices +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toPlaceholderContext import org.bukkit.entity.Player object ConditionCanAffordPrice : Condition("can_afford_price") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt index 0571c0e5d..4e5b93029 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionGlobalPointsEqual.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.globalPoints -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.globalPoints import org.bukkit.entity.Player object ConditionGlobalPointsEqual : Condition("global_points_equal") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt index e0c50752c..bf945e988 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasItemData.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData -import com.willfp.libreforge.Dispatcher import org.bukkit.inventory.ItemStack object ConditionHasItemData : Condition("has_item_data") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt index e1685e98e..e821f4797 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPermission.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt index 8286ffba5..e2fe246ad 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionHasPotionEffect.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.containsIgnoreCase +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt index 6b09885ff..c3a81c741 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInAir.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher object ConditionInAir : Condition("in_air") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt index 0a9303f63..1c53d510f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBiome.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher object ConditionInBiome : Condition("in_biome") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt index 95a8f52ac..9c6e628ea 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInBlock.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt index 019f0cf32..26bf7156e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInMainhand.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionInMainhand : ItemCondition("in_mainhand") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt index ec1d63a83..6d6325055 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWater.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt index bf825a2fd..896f47b8a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionInWorld.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher object ConditionInWorld : Condition("in_world") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt index 73f791bf9..30c4e9234 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsExpressionTrue.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt index efd8fbe90..f7a33922a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFalling.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt index 2fdb6f154..bd18fed31 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFlying.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt index 40307099e..d07bbbb50 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsFrozen.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.LivingEntity diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt index 3d2505bfa..eaa159012 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsGliding.kt @@ -1,15 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityToggleGlideEvent @@ -28,7 +27,6 @@ object ConditionIsGliding : Condition("is_gliding") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityToggleGlideEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt index f4a2b72ab..212536faf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsNight.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher object ConditionIsNight : Condition("is_night") { override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt index ca3cfa881..f0c525353 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsOp.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt index 00e0fd320..b6e3f09fc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSneaking.kt @@ -1,12 +1,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -27,7 +27,6 @@ object ConditionIsSneaking : Condition("is_sneaking") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerToggleSneakEvent) { - val dispatcher = EntityDispatcher(event.player) - dispatcher.updateEffects() + event.player.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt index 2bdef26a3..5f69e272a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSprinting.kt @@ -1,12 +1,12 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -27,7 +27,6 @@ object ConditionIsSprinting : Condition("is_sprinting") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerToggleSprintEvent) { - val dispatcher = EntityDispatcher(event.player) - dispatcher.updateEffects() + event.player.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt index 5f6b54617..a2cf9b165 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsStorm.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -25,8 +25,7 @@ object ConditionIsStorm: Condition("is_storm") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: WeatherChangeEvent) { for (entity in event.world.entities) { - val dispatcher = EntityDispatcher(entity) - dispatcher.updateEffects() + entity.toDispatcher().updateEffects() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt index 71ca38cbf..ed9a4fa39 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionIsSwimming.kt @@ -1,15 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityToggleSwimEvent @@ -28,7 +27,6 @@ object ConditionIsSwimming : Condition("is_swimming") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityToggleSwimEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt index 8e986a361..b78edfaaa 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemDataEquals.kt @@ -2,14 +2,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.itemData -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt index b42bfa17c..5eac22086 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelAbove.kt @@ -1,15 +1,15 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt index 721a15c45..c55d1007b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelBelow.kt @@ -1,15 +1,15 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt index 28e8950b6..76b4b6c0b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemLevelEquals.kt @@ -1,15 +1,15 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.levels.LevelTypes import com.willfp.libreforge.levels.levels -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt index e3079b1b8..1168775f0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsAbove.kt @@ -1,14 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt index aa6973924..129d72a10 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsBelow.kt @@ -1,14 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt index 64f555c41..2d775dace 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionItemPointsEqual.kt @@ -1,14 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition +import com.willfp.libreforge.get import com.willfp.libreforge.getProvider import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt index 2d05c587f..4311fcd74 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionNearEntity.kt @@ -4,11 +4,11 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity import com.willfp.eco.core.entities.impl.EmptyTestableEntity +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get object ConditionNearEntity : Condition>("near_entity") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt index 72339f6e0..6601a63ec 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnFire.kt @@ -1,15 +1,14 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.entity.EntityDamageEvent @@ -36,7 +35,6 @@ object ConditionOnFire : Condition("on_fire") { return } - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt index 6aa1e70ff..684bdb03a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionOnGround.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import org.bukkit.block.BlockFace object ConditionOnGround : Condition("on_ground") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt index 32f254a7e..39ede4ca9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderContains.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt index 4a4d19605..21400dba3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderEquals.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt index 55b940b36..2698804f5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderGreaterThan.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt index daa1d285f..6c82d199d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPlaceholderLessThan.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.context.placeholderContext +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt index 27cce20bf..cf122ae49 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionPointsEqual.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.points import org.bukkit.entity.Player object ConditionPointsEqual : Condition("points_equal") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt index c9aa55dbc..6a288f3b1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionRidingEntity.kt @@ -3,16 +3,15 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Entity -import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.spigotmc.event.entity.EntityDismountEvent @@ -42,13 +41,11 @@ object ConditionRidingEntity : Condition>("riding_ent @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityDismountEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: EntityMountEvent) { - val dispatcher = EntityDispatcher(event.entity) - dispatcher.updateEffects() + event.entity.toDispatcher().updateEffects() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt index e1db57a28..c04c449f6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionStandingOnBlock.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt index 08be85ed5..8a03ee983 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingBoots.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingBoots : ItemCondition("wearing_boots") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt index f06d56ed1..7f50c0f74 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingChestplate.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingChestplate : ItemCondition("wearing_chestplate") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt index afe933118..5cde5b487 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingHelmet.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingHelmet : ItemCondition("wearing_helmet") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt index 661274677..3bd318f3b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWearingLeggings.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.util.toSingletonList import com.willfp.libreforge.conditions.templates.ItemCondition import org.bukkit.entity.LivingEntity -import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack object ConditionWearingLeggings : ItemCondition("wearing_leggings") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt index 5328261aa..a8471eb37 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/impl/ConditionWithinRadiusOf.kt @@ -1,11 +1,11 @@ package com.willfp.libreforge.conditions.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.util.Vector import kotlin.math.pow diff --git a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt index 766a8d0ae..020b8117f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/conditions/templates/ItemCondition.kt @@ -4,14 +4,14 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.TestableItem import com.willfp.eco.core.recipe.parts.EmptyTestableItem +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.getStrings -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.getStrings import org.bukkit.entity.LivingEntity import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt index 94fd92d43..89175988f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/counters/bind/BoundCounter.kt @@ -4,8 +4,8 @@ import com.willfp.eco.core.placeholder.context.placeholderContext import com.willfp.eco.util.evaluateExpression import com.willfp.libreforge.counters.Accumulator import com.willfp.libreforge.counters.Counter -import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.get +import com.willfp.libreforge.triggers.DispatchedTrigger import org.bukkit.entity.Player /* diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt index 8d5db0425..e62d7f91e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Chain.kt @@ -1,14 +1,14 @@ package com.willfp.libreforge.effects import com.willfp.libreforge.DelegatedList +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.WeightedList import com.willfp.libreforge.effects.executors.ChainExecutor +import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData -import com.willfp.libreforge.get import com.willfp.libreforge.triggers.impl.TriggerBlank import org.bukkit.entity.Player @@ -43,7 +43,7 @@ class Chain internal constructor( @Deprecated( "Use trigger(Dispatcher<*>, TriggerData, Trigger, ChainExecutor)", - ReplaceWith("trigger(dispatcher, data, trigger, executor)"), + ReplaceWith("trigger(player.toDispatcher(), data, trigger, executor)"), DeprecationLevel.ERROR ) fun trigger( @@ -52,6 +52,6 @@ class Chain internal constructor( trigger: Trigger = TriggerBlank, executor: ChainExecutor = this.executor ): Boolean { - return trigger(EntityDispatcher(player), data, trigger, executor) + return trigger(player.toDispatcher(), data, trigger, executor) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt index 07808c69a..0c2b9bb70 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/ChainElement.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.Compiled +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.Weighted import com.willfp.libreforge.conditions.ConditionList @@ -10,9 +11,8 @@ import com.willfp.libreforge.effects.events.EffectDisableEvent import com.willfp.libreforge.effects.events.EffectEnableEvent import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import org.bukkit.Bukkit import org.bukkit.entity.Player import java.util.UUID @@ -69,23 +69,23 @@ class ChainElement internal constructor( @Deprecated( "Use enable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("enable(dispatcher, holder, isReload)"), + ReplaceWith("enable(player.toDispatcher(), holder, isReload)"), DeprecationLevel.ERROR ) fun enable( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = enable(EntityDispatcher(player), holder, isReload) + ): Unit = enable(player.toDispatcher(), holder, isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("disable(dispatcher, holder, isReload)"), + ReplaceWith("disable(player.toDispatcher(), holder, isReload)"), DeprecationLevel.ERROR ) fun disable( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(EntityDispatcher(player), holder, isReload) + ): Unit = disable(player.toDispatcher(), holder, isReload) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt index aaebf4b21..f79dce334 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/Effect.kt @@ -3,19 +3,19 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.defaultMap import com.willfp.libreforge.Compilable +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.applyHolder +import com.willfp.libreforge.ifType import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.mutators.emptyMutatorList import com.willfp.libreforge.plugin +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import com.willfp.libreforge.triggers.Triggers -import com.willfp.libreforge.ifType import org.bukkit.entity.Player import org.bukkit.event.Listener import java.util.UUID @@ -211,7 +211,7 @@ abstract class Effect( @Deprecated( "Use enable(Dispatcher<*>, ProvidedHolder, ChainElement, Boolean)", - ReplaceWith("enable(dispatcher, holder, config, isReload)"), + ReplaceWith("enable(player.toDispatcher(), holder, config, isReload)"), DeprecationLevel.ERROR ) fun enable( @@ -219,11 +219,11 @@ abstract class Effect( holder: ProvidedHolder, config: ChainElement, isReload: Boolean = false - ) = enable(EntityDispatcher(player), holder, config, isReload) + ): Unit = enable(player.toDispatcher(), holder, config, isReload) @Deprecated( "Use enable(Dispatcher<*>, ProvidedHolder, ChainElement, Boolean)", - ReplaceWith("enable(dispatcher, holder, config, isReload)") + ReplaceWith("enable(player.toDispatcher(), holder, config, isReload)") ) protected open fun onEnable( player: Player, @@ -237,18 +237,18 @@ abstract class Effect( @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("disable(dispatcher, holder, isReload)"), + ReplaceWith("disable(player.toDispatcher(), holder, isReload)"), DeprecationLevel.ERROR ) fun disable( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(EntityDispatcher(player), holder, isReload) + ): Unit = disable(player.toDispatcher(), holder, isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("disable(dispatcher, holder, isReload)") + ReplaceWith("disable(player.toDispatcher(), holder, isReload)") ) protected open fun onDisable( player: Player, diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt index a147e2169..fe2d0be2a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/EffectBlock.kt @@ -1,14 +1,14 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.arguments.EffectArgumentList import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.PotentiallyTriggerable import com.willfp.libreforge.triggers.Trigger import org.bukkit.entity.Player @@ -53,7 +53,7 @@ class EffectBlock internal constructor( @Deprecated( "Use enable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("enable(dispatcher, holder, isReload)"), + ReplaceWith("enable(player.toDispatcher(), holder, isReload)"), DeprecationLevel.ERROR ) @JvmOverloads @@ -61,11 +61,11 @@ class EffectBlock internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = enable(EntityDispatcher(player), holder, isReload = isReload) + ): Unit = enable(player.toDispatcher(), holder, isReload = isReload) @Deprecated( "Use disable(Dispatcher<*>, ProvidedHolder, Boolean)", - ReplaceWith("disable(dispatcher, holder, isReload)"), + ReplaceWith("disable(player.toDispatcher(), holder, isReload)"), DeprecationLevel.ERROR ) @JvmOverloads @@ -73,7 +73,7 @@ class EffectBlock internal constructor( player: Player, holder: ProvidedHolder, isReload: Boolean = false - ) = disable(EntityDispatcher(player), holder, isReload = isReload) + ): Unit = disable(player.toDispatcher(), holder, isReload = isReload) fun tryTrigger(trigger: DispatchedTrigger) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt index f9b59fb71..400cf40f1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/RichChain.kt @@ -1,16 +1,11 @@ package com.willfp.libreforge.effects import com.willfp.eco.core.config.interfaces.Config -import com.willfp.libreforge.BlankHolder.effects -import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.effects.arguments.EffectArgumentList import com.willfp.libreforge.filters.FilterList import com.willfp.libreforge.mutators.MutatorList import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.triggers.PotentiallyTriggerable -import com.willfp.libreforge.triggers.Trigger -import org.bukkit.entity.Player import java.util.Objects import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/EffectArgument.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/EffectArgument.kt index 7ea86517a..032f7c1a0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/EffectArgument.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/EffectArgument.kt @@ -2,7 +2,6 @@ package com.willfp.libreforge.effects.arguments import com.willfp.libreforge.Compilable import com.willfp.libreforge.ConfigurableElement -import com.willfp.libreforge.effects.ElementLike import com.willfp.libreforge.effects.RunOrder import com.willfp.libreforge.triggers.DispatchedTrigger diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/custom/CustomEffectArguments.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/custom/CustomEffectArguments.kt index e42c5500e..8f5cb97ef 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/custom/CustomEffectArguments.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/custom/CustomEffectArguments.kt @@ -4,8 +4,6 @@ import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.registry.Registry import com.willfp.libreforge.configs.category.NativeConfigCategory -import com.willfp.libreforge.effects.arguments.EffectArgument -import com.willfp.libreforge.levels.LevelType object CustomEffectArguments : NativeConfigCategory("arguments") { private val registry = Registry() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt index c27520227..6a2ba49b9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentChainArgs.kt @@ -5,8 +5,8 @@ import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NamedValue import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument -import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.get +import com.willfp.libreforge.triggers.DispatchedTrigger object ArgumentChainArgs : EffectArgument("chain_args") { // Misusing arguments a bit here but it's surprisingly clean diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt index ca9c7bd5e..187ae3b21 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCooldown.kt @@ -11,9 +11,9 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.arguments.EffectArgument import com.willfp.libreforge.getDoubleFromExpression +import com.willfp.libreforge.ifType import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.ifType import org.bukkit.Sound import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt index 8b156cd99..c04efb107 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentCost.kt @@ -7,10 +7,10 @@ import com.willfp.eco.util.StringUtils import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument +import com.willfp.libreforge.get import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt index 056fe4e15..758a2b4d8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentEvery.kt @@ -1,9 +1,9 @@ package com.willfp.libreforge.effects.arguments.impl import com.willfp.eco.core.map.nestedMap +import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument -import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.DispatchedTrigger import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt index 63feb0ab1..7401ba5f0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPointCost.kt @@ -6,12 +6,12 @@ import com.willfp.eco.util.StringUtils import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument +import com.willfp.libreforge.get import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt index 34b682a34..047529ec9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/arguments/impl/ArgumentPrice.kt @@ -7,10 +7,10 @@ import com.willfp.eco.util.StringUtils import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument +import com.willfp.libreforge.get import com.willfp.libreforge.plugin import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt index facd4fadb..83f91d2b6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectDisableEvent.kt @@ -1,8 +1,8 @@ package com.willfp.libreforge.effects.events +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.Event @@ -17,7 +17,7 @@ class EffectDisableEvent( @Deprecated( "Use dispatcher.get()", - ReplaceWith("dispatcher.get()"), + ReplaceWith("toDispatcher().get()"), DeprecationLevel.ERROR ) val player: Player? diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt index 66c0d9f44..666d7d374 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/events/EffectEnableEvent.kt @@ -1,8 +1,8 @@ package com.willfp.libreforge.effects.events +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player import org.bukkit.event.Event @@ -17,7 +17,7 @@ class EffectEnableEvent( @Deprecated( "Use dispatcher.get()", - ReplaceWith("dispatcher.get()"), + ReplaceWith("toDispatcher().get()"), DeprecationLevel.ERROR ) val player: Player? diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt index e537ea96e..e0cb51d07 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOE.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +40,7 @@ object EffectAOE : Effect("aoe") { data.copy( victim = entity, location = entity.location - ).dispatch(EntityDispatcher(player)) + ).dispatch(player.toDispatcher()) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt index 4ed2db6d9..5d33a91c5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAOEBlocks.kt @@ -7,8 +7,8 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.impl.aoe.AOECompileData import com.willfp.libreforge.effects.impl.aoe.AOEShapes +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.toFloat3 -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -41,7 +41,7 @@ object EffectAOEBlocks : Effect("aoe_blocks") { data.copy( block = block, location = block.location.add(0.5, 0.5, 0.5) - ).dispatch(EntityDispatcher(player)) + ).dispatch(player.toDispatcher()) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt index 0ae208759..ad1277c80 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolder.kt @@ -12,7 +12,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerDispatcherHolderProvider +import com.willfp.libreforge.registerGenericHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import java.util.UUID @@ -31,7 +31,7 @@ object EffectAddHolder : Effect("add_holder") { private val holders = listMap() init { - registerDispatcherHolderProvider { + registerGenericHolderProvider { holders[it.uuid].map { h -> SimpleProvidedHolder(h) } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt index 8cd36a55d..7f8a8321f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderInRadius.kt @@ -14,7 +14,7 @@ import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerDispatcherHolderProvider +import com.willfp.libreforge.registerGenericHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.Location @@ -41,7 +41,7 @@ object EffectAddHolderInRadius : Effect("add_holder_in_radius") .build>() init { - registerDispatcherHolderProvider { dispatcher -> + registerGenericHolderProvider { dispatcher -> nearbyCache.get(dispatcher.uuid) { _ -> holders.filter { it.canApplyTo(dispatcher) } .map { SimpleProvidedHolder(it.holder) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt index c44dd6b2d..19d781a86 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddHolderToVictim.kt @@ -12,7 +12,7 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.registerDispatcherHolderProvider +import com.willfp.libreforge.registerGenericHolderProvider import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.Player @@ -32,7 +32,7 @@ object EffectAddHolderToVictim : Effect("add_holder_to_victim") private val holders = listMap() init { - registerDispatcherHolderProvider { holders[it.uuid].map { h -> SimpleProvidedHolder(h) } } + registerGenericHolderProvider { holders[it.uuid].map { h -> SimpleProvidedHolder(h) } } } override fun onTrigger(config: Config, data: TriggerData, compileData: HolderTemplate): Boolean { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt index 3e730e9e1..f169483d8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPermanentHolderInRadius.kt @@ -2,6 +2,7 @@ package com.willfp.libreforge.effects.impl import com.github.benmanes.caffeine.cache.Caffeine import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.Holder import com.willfp.libreforge.HolderTemplate import com.willfp.libreforge.ProvidedHolder @@ -12,9 +13,8 @@ import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.registerDispatcherHolderProvider -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.registerGenericHolderProvider import org.bukkit.Bukkit import java.util.Objects import java.util.UUID @@ -34,7 +34,7 @@ object EffectAddPermanentHolderInRadius : Effect("add_permanent_ .build>() init { - registerDispatcherHolderProvider { dispatcher -> + registerGenericHolderProvider { dispatcher -> nearbyCache.get(dispatcher.uuid) { _ -> holders.filter { it.canApplyTo(dispatcher) } .map { SimpleProvidedHolder(it.holder) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt index 64ec03464..2a4f80bb8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAddPoints.kt @@ -2,14 +2,14 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.nestedMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.points -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.points import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt index 520cbb16a..1729f89c0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectAllPlayers.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -21,7 +21,7 @@ object EffectAllPlayers : Effect("all_players") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { for (player in Bukkit.getOnlinePlayers()) { compileData?.trigger( - data.dispatch(EntityDispatcher(player)), + data.dispatch(player.toDispatcher()), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBleed.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBleed.kt index 65519c955..2b05f2a40 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBleed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBleed.kt @@ -8,7 +8,6 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.plugin -import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import com.willfp.libreforge.triggers.impl.TriggerKill diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt index 65ecf1334..0208a9ed1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBlockCommands.kt @@ -3,12 +3,12 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.nestedListMap import com.willfp.eco.util.formatEco +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.Dispatcher import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerCommandPreprocessEvent import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBreakBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBreakBlock.kt index 1e765760b..30f1c5bb5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBreakBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBreakBlock.kt @@ -1,10 +1,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.util.runExempted import com.willfp.libreforge.NoCompileData -import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.impl.EffectMineVein.breakBlocksSafely import com.willfp.libreforge.effects.templates.MineBlockEffect import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt index 8c91b6e92..4fba6d90c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBrewTimeMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.block.BrewingStand import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -15,7 +15,7 @@ object EffectBrewTimeMultiplier : MultiplierEffect("brew_time_multiplier") { fun handle(event: InventoryClickEvent) { val player = event.whoClicked as? Player ?: return - val multiplier = getMultiplier(EntityDispatcher(player)) + val multiplier = getMultiplier(player.toDispatcher()) if (player.openInventory.topInventory.holder !is BrewingStand) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCloseInventory.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCloseInventory.kt index 774b0ecbc..d1f2ec316 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCloseInventory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCloseInventory.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.util.runExempted import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.triggers.TriggerData diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt index 037578c30..13653f523 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectConsumeHeldItem.kt @@ -1,14 +1,13 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getIntFromExpression +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter -import com.willfp.libreforge.updateEffects import com.willfp.libreforge.updateHolders import org.bukkit.Material @@ -37,7 +36,7 @@ object EffectConsumeHeldItem : Effect("consume_held_item") { player.inventory.setItemInMainHand(item) - EntityDispatcher(player).updateHolders() + player.toDispatcher().updateHolders() return true } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCreateBossBar.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCreateBossBar.kt index 403099209..0836f062d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCreateBossBar.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectCreateBossBar.kt @@ -1,13 +1,9 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.drops.DropQueue -import com.willfp.eco.core.items.Items import com.willfp.eco.core.placeholder.translatePlaceholders -import com.willfp.eco.util.asAudience import com.willfp.eco.util.toComponent import com.willfp.libreforge.NoCompileData -import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.impl.bossbar.BossBars @@ -19,7 +15,6 @@ import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import net.kyori.adventure.bossbar.BossBar -import org.bukkit.inventory.ItemStack object EffectCreateBossBar : Effect("create_boss_bar") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDamageItem.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDamageItem.kt index c5e68d7e4..a4ae44611 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDamageItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDamageItem.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.toSingletonList -import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.DamageItemEffect import com.willfp.libreforge.triggers.TriggerData import org.bukkit.inventory.ItemStack diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt index 28fe27fc7..534df5d40 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeLapisChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.Material import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -15,7 +15,7 @@ object EffectDontConsumeLapisChance : ChanceMultiplierEffect("dont_consume_lapis val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(EntityDispatcher(player))) { + if (!passesChance(player.toDispatcher())) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt index 8aea50b12..6daa524f3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectDontConsumeXpChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.enchantment.EnchantItemEvent @@ -13,7 +13,7 @@ object EffectDontConsumeXpChance : ChanceMultiplierEffect("dont_consume_xp_chanc val player = event.enchanter val cost = event.whichButton() + 1 - if (!passesChance(EntityDispatcher(player))) { + if (!passesChance(player.toDispatcher())) { return } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt index b39b8c001..7f5d24895 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFeatherStep.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.Dispatcher import org.bukkit.Tag import org.bukkit.event.EventHandler import org.bukkit.event.block.Action diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt index 0d88cfe90..f16181d10 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFlight.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Player import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt index f8e0e6083..eb9e2ea7c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectFoodMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent @@ -18,6 +18,6 @@ object EffectFoodMultiplier : MultiplierEffect("food_multiplier") { return } - event.foodLevel = player.foodLevel + ceil(getMultiplier(EntityDispatcher(player)) * diff).toInt() + event.foodLevel = player.foodLevel + ceil(getMultiplier(player.toDispatcher()) * diff).toInt() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGiveSaturation.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGiveSaturation.kt index b6d691dda..0195ce136 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGiveSaturation.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGiveSaturation.kt @@ -5,7 +5,6 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGlowNearbyBlocks.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGlowNearbyBlocks.kt index 292de159e..3f57c64b3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGlowNearbyBlocks.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectGlowNearbyBlocks.kt @@ -2,7 +2,6 @@ package com.willfp.libreforge.effects.impl -import com.gmail.nossr50.config.ChatConfig import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.TeamUtils import com.willfp.libreforge.NoCompileData diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt index 3e2d4ab8f..d8c3b1803 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectHungerMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.NumberUtils import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.FoodLevelChangeEvent import kotlin.math.ceil @@ -18,14 +18,14 @@ object EffectHungerMultiplier : MultiplierEffect("hunger_multiplier") { return } - val multiplier = getMultiplier(EntityDispatcher(entity)) + val multiplier = getMultiplier(entity.toDispatcher()) if (multiplier < 1) { if (NumberUtils.randFloat(0.0, 1.0) > multiplier) { event.isCancelled = true } } else { - event.foodLevel = entity.foodLevel + ceil(diff * getMultiplier(EntityDispatcher(entity))).toInt() + event.foodLevel = entity.foodLevel + ceil(diff * getMultiplier(entity.toDispatcher())).toInt() } } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt index 4afdd6f49..6dbe22181 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectKeepInventory.kt @@ -2,11 +2,11 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.Dispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.PlayerDeathEvent import java.util.UUID diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMineVein.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMineVein.kt index 20012f029..e2562742d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMineVein.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectMineVein.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.eco.util.BlockUtils -import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.templates.MineBlockEffect diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectParticleLine.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectParticleLine.kt index d934d6110..3a891075e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectParticleLine.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectParticleLine.kt @@ -5,7 +5,6 @@ import com.willfp.eco.core.particle.Particles import com.willfp.eco.core.particle.SpawnableParticle import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments -import com.willfp.libreforge.distance import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt index b99eb4027..97666aae2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPermanentPotionEffect.kt @@ -2,14 +2,14 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.Prerequisite import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.plugin import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerRespawnEvent diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt index 5e75f58c0..6eba3791c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectPotionDurationMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.util.duration import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -26,9 +26,7 @@ object EffectPotionDurationMultiplier : MultiplierEffect("potion_duration_multip fun handle(event: BrewEvent) { val player = event.contents.viewers.filterIsInstance().firstOrNull() ?: return - val multiplier = getMultiplier( - EntityDispatcher(player) - ) + val multiplier = getMultiplier(player.toDispatcher()) plugin.scheduler.run { for (i in 0..2) { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt index 4817524cb..57f9d816f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRandomPlayer.kt @@ -7,7 +7,7 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.TriggerData import org.bukkit.Bukkit @@ -21,7 +21,7 @@ object EffectRandomPlayer : Effect("random_player") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { Bukkit.getOnlinePlayers().randomOrNull()?.let { player -> compileData?.trigger( - data.dispatch(EntityDispatcher(player)), + data.dispatch(player.toDispatcher()), ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt index da1d0be9b..ea744aa39 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRapidBows.kt @@ -2,13 +2,13 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.Dispatcher +import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.get import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt index 9a9d9bc45..23df6a185 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReelSpeedMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiplierEffect import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.player.PlayerFishEvent @@ -19,7 +19,7 @@ object EffectReelSpeedMultiplier : MultiplierEffect("reel_speed_multiplier") { val player = event.player - val multiplier = getMultiplier(EntityDispatcher(player)) + val multiplier = getMultiplier(player.toDispatcher()) if (multiplier == 1.0) { return diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt index f0bebebf9..ea9d888cb 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRegenMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.libreforge.effects.templates.MultiMultiplierEffect import com.willfp.libreforge.enumValueOfOrNull -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler import org.bukkit.event.entity.EntityRegainHealthEvent import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason @@ -18,6 +18,6 @@ object EffectRegenMultiplier : MultiMultiplierEffect("regen_multip @EventHandler(ignoreCancelled = true) fun handle(event: EntityRegainHealthEvent) { - event.amount *= getMultiplier(EntityDispatcher(event.entity), event.regainReason) + event.amount *= getMultiplier(event.entity.toDispatcher(), event.regainReason) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveBossBar.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveBossBar.kt index 213f67b8c..879138e62 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveBossBar.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveBossBar.kt @@ -6,7 +6,6 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.impl.bossbar.BossBars -import com.willfp.libreforge.effects.impl.bossbar.RegistrableBossBar import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.TriggerData diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveItemData.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveItemData.kt index c46141758..5623d9639 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveItemData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRemoveItemData.kt @@ -1,14 +1,10 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.placeholder.translatePlaceholders import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getFormattedString import com.willfp.libreforge.itemData -import com.willfp.libreforge.points import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplaceNear.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplaceNear.kt index e8464bba2..16ec43686 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplaceNear.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplaceNear.kt @@ -7,7 +7,6 @@ import com.willfp.eco.util.containsIgnoreCase import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.templates.MineBlockEffect import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.getOrNull import com.willfp.libreforge.plugin diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt index aa5ca812e..2bbba5a71 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectReplantCrops.kt @@ -3,13 +3,13 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.block.BlockFace diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt index 6a4a3c4bd..a0c058a2a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChain.kt @@ -8,8 +8,8 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object EffectRunChain : Effect("run_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(EntityDispatcher(player)) + val dispatch = data.dispatch(player.toDispatcher()) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt index 49609f8b8..6fba6295a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunChainInline.kt @@ -9,8 +9,8 @@ import com.willfp.libreforge.effects.Chain import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.toPlaceholderContext -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object EffectRunChainInline : Effect("run_chain_inline") { override fun onTrigger(config: Config, data: TriggerData, compileData: Chain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(EntityDispatcher(player)) + val dispatch = data.dispatch(player.toDispatcher()) val args = config.getSubsection("chain_args") diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunCommand.kt index 84aa70b9f..bffa93bed 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunCommand.kt @@ -2,7 +2,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.translatePlaceholders -import com.willfp.eco.util.formatEco import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunPlayerCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunPlayerCommand.kt index ca0bc923a..2da0d0f19 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunPlayerCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectRunPlayerCommand.kt @@ -2,7 +2,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.placeholder.translatePlaceholders -import com.willfp.eco.util.formatEco import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt index 68f16bc83..c40a281b1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSellMultiplier.kt @@ -2,12 +2,12 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectSellMultiplier : MultiplierEffect("sell_multiplier") { @EventHandler fun handle(event: ShopSellEvent) { - event.multiplier *= getMultiplier(EntityDispatcher(event.player)) + event.multiplier *= getMultiplier(event.player.toDispatcher()) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetArmorTrim.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetArmorTrim.kt index 549f4aded..2df76da6c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetArmorTrim.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetArmorTrim.kt @@ -10,8 +10,6 @@ import org.bukkit.NamespacedKey import org.bukkit.Registry import org.bukkit.inventory.meta.ArmorMeta import org.bukkit.inventory.meta.trim.ArmorTrim -import org.bukkit.inventory.meta.trim.TrimMaterial -import org.bukkit.inventory.meta.trim.TrimPattern object EffectSetArmorTrim : Effect("set_armor_trim") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemData.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemData.kt index 1498fb902..d7e07b750 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSetItemData.kt @@ -1,14 +1,11 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.core.placeholder.translatePlaceholders import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getFormattedString import com.willfp.libreforge.itemData -import com.willfp.libreforge.points import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt index 0d3124d2c..93bd7fa56 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectShoot.kt @@ -1,6 +1,5 @@ package com.willfp.libreforge.effects.impl -import com.gamingmesh.jobs.commands.list.fire import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.util.runExempted import com.willfp.libreforge.NoCompileData diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSwarm.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSwarm.kt index 99faba98c..b6ed5f0e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSwarm.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectSwarm.kt @@ -3,9 +3,6 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.entities.Entities import com.willfp.eco.core.entities.TestableEntity -import com.willfp.eco.core.lookup.matches -import com.willfp.libreforge.ConfigArguments -import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect @@ -13,7 +10,6 @@ import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.Monster -import org.checkerframework.checker.units.qual.t object EffectSwarm : Effect?>("swarm") { override val parameters = setOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt index a135bfc99..181c97102 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTelekinesis.kt @@ -7,12 +7,12 @@ import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.eco.core.map.listMap import com.willfp.eco.util.TelekinesisUtils import com.willfp.eco.util.tryAsPlayer +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import org.bukkit.GameMode import org.bukkit.Material import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt index d05d8349a..a3a5610bc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectTriggerNestedChain.kt @@ -5,7 +5,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.RichChain -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +24,7 @@ object EffectTriggerNestedChain : Effect("trigger_nested_chain") { override fun onTrigger(config: Config, data: TriggerData, compileData: RichChain?): Boolean { val player = data.player ?: return false - val dispatch = data.dispatch(EntityDispatcher(player)) + val dispatch = data.dispatch(player.toDispatcher()) return compileData?.trigger(dispatch) == true } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectVictimSpeedMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectVictimSpeedMultiplier.kt index 9a0995e5a..6a6db3d2b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectVictimSpeedMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectVictimSpeedMultiplier.kt @@ -6,7 +6,6 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression -import com.willfp.libreforge.getOrNull import com.willfp.libreforge.plugin import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt index b6d9ebfeb..ce792cc7a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectXpMultiplier.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.effects.impl import com.willfp.eco.core.events.NaturalExpGainEvent import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler import kotlin.math.ceil @@ -11,7 +11,7 @@ object EffectXpMultiplier : MultiplierEffect("xp_multiplier") { fun handle(event: NaturalExpGainEvent) { val player = event.expChangeEvent.player - val multiplier = getMultiplier(EntityDispatcher(player)) + val multiplier = getMultiplier(player.toDispatcher()) event.expChangeEvent.amount = ceil(event.expChangeEvent.amount * multiplier).toInt() } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCircle.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCircle.kt index d1c30c5ee..26543eb79 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCircle.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCircle.kt @@ -5,7 +5,6 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.impl.aoe.AOEShape import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getNearbyBlocks import com.willfp.libreforge.getNearbyBlocksInSphere import com.willfp.libreforge.toLocation import com.willfp.libreforge.triggers.TriggerData diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCone.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCone.kt index f2ac97bbb..82b2b91e5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCone.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeCone.kt @@ -6,7 +6,6 @@ import com.willfp.libreforge.angle import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.impl.aoe.AOEShape import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getNearbyBlocks import com.willfp.libreforge.getNearbyBlocksInSphere import com.willfp.libreforge.toFloat3 import com.willfp.libreforge.toLocation diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeOffsetCircle.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeOffsetCircle.kt index c1f0c7214..3afa56d82 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeOffsetCircle.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeOffsetCircle.kt @@ -5,7 +5,6 @@ import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.impl.aoe.AOEShape import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getNearbyBlocks import com.willfp.libreforge.getNearbyBlocksInSphere import com.willfp.libreforge.normalize import com.willfp.libreforge.toLocation diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeScanInFront.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeScanInFront.kt index ad09da7a0..5278efd86 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeScanInFront.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/aoe/impl/AOEShapeScanInFront.kt @@ -6,7 +6,6 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.impl.aoe.AOEShape import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.getIntFromExpression -import com.willfp.libreforge.getNearbyBlocks import com.willfp.libreforge.getNearbyBlocksInSphere import com.willfp.libreforge.normalize import com.willfp.libreforge.plusAssign diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/bossbar/BossBars.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/bossbar/BossBars.kt index fcafa1b77..a7ceb6aa0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/bossbar/BossBars.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/bossbar/BossBars.kt @@ -1,14 +1,9 @@ package com.willfp.libreforge.effects.impl.bossbar import com.willfp.eco.core.map.listMap -import com.willfp.eco.core.placeholder.DynamicPlaceholder import com.willfp.eco.util.asAudience -import com.willfp.eco.util.toNiceString -import com.willfp.libreforge.effects.executors.ChainExecutors.getByID -import com.willfp.libreforge.plugin import net.kyori.adventure.bossbar.BossBar import org.bukkit.Bukkit -import java.util.regex.Pattern object BossBars { private val registry = listMap() diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt index 641e0bedb..03365617f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/AttributeEffect.kt @@ -1,13 +1,13 @@ package com.willfp.libreforge.effects.templates import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.plugin import org.bukkit.attribute.Attribute import org.bukkit.attribute.AttributeInstance import org.bukkit.attribute.AttributeModifier diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt index 27ff006c8..0d1e8e8f6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/ChanceMultiplierEffect.kt @@ -3,15 +3,15 @@ package com.willfp.libreforge.effects.templates import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap import com.willfp.eco.util.randDouble +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import java.util.UUID @@ -50,9 +50,9 @@ abstract class ChanceMultiplierEffect(id: String) : Effect(id) { @Deprecated( "Use passesChance(dispatcher: Dispatcher<*>) instead.", - ReplaceWith("passesChance(dispatcher)"), + ReplaceWith("passesChance(player.toDispatcher())"), DeprecationLevel.ERROR ) protected fun passesChance(player: Player): Boolean = - passesChance(EntityDispatcher(player)) + passesChance(player.toDispatcher()) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/DamageItemEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/DamageItemEffect.kt index 6d9b0f482..92d94580f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/DamageItemEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/DamageItemEffect.kt @@ -7,7 +7,6 @@ import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.TriggerData -import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.Bukkit import org.bukkit.Material import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt index e880b4aad..922474ad5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiMultiplierEffect.kt @@ -3,15 +3,15 @@ package com.willfp.libreforge.effects.templates import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap import com.willfp.eco.core.map.nestedListMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import java.util.UUID @@ -74,11 +74,11 @@ abstract class MultiMultiplierEffect(id: String) : Effect, element: T) instead.", - ReplaceWith("getMultiplier(dispatcher, element)"), + ReplaceWith("getMultiplier(player.toDispatcher(), element)"), DeprecationLevel.ERROR ) protected fun getMultiplier(player: Player, element: T): Double = - getMultiplier(EntityDispatcher(player), element) + getMultiplier(player.toDispatcher(), element) /** * Get an element by [key], for example a stat. diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt index 70105fa3a..1f1eeb201 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/templates/MultiplierEffect.kt @@ -2,15 +2,15 @@ package com.willfp.libreforge.effects.templates import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect -import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.effects.IdentifiedModifier -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.effects.Identifiers import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import java.util.UUID @@ -49,9 +49,9 @@ abstract class MultiplierEffect(id: String) : Effect(id) { @Deprecated( "Use getMultiplier(dispatcher: Dispatcher<*>) instead.", - ReplaceWith("getMultiplier(dispatcher)"), + ReplaceWith("getMultiplier(player.toDispatcher())"), DeprecationLevel.ERROR ) protected fun getMultiplier(player: Player): Double = - getMultiplier(EntityDispatcher(player)) + getMultiplier(player.toDispatcher()) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt index 1551b7b62..b8aade1a7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/Filters.kt @@ -9,13 +9,13 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.deprecationMessage import com.willfp.libreforge.filters.impl.FilterAboveHealthPercent import com.willfp.libreforge.filters.impl.FilterBlocks -import com.willfp.libreforge.filters.impl.FilterIsBoss import com.willfp.libreforge.filters.impl.FilterDamageCause import com.willfp.libreforge.filters.impl.FilterEntities import com.willfp.libreforge.filters.impl.FilterFromSpawner import com.willfp.libreforge.filters.impl.FilterFullyCharged import com.willfp.libreforge.filters.impl.FilterFullyGrown import com.willfp.libreforge.filters.impl.FilterIsBehindVictim +import com.willfp.libreforge.filters.impl.FilterIsBoss import com.willfp.libreforge.filters.impl.FilterIsExpressionTrue import com.willfp.libreforge.filters.impl.FilterIsNPC import com.willfp.libreforge.filters.impl.FilterIsPassive diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsBehindVictim.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsBehindVictim.kt index 3c7a8ad14..66fcd44e8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsBehindVictim.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsBehindVictim.kt @@ -2,13 +2,11 @@ package com.willfp.libreforge.filters.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData -import com.willfp.libreforge.angle import com.willfp.libreforge.dot import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.toFloat3 import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.xz -import kotlin.math.roundToInt object FilterIsBehindVictim : Filter("is_behind_victim") { override fun getValue(config: Config, data: TriggerData?, key: String): Boolean { diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsPassive.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsPassive.kt index 7b30d8eec..78cb9f41e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsPassive.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterIsPassive.kt @@ -1,15 +1,11 @@ package com.willfp.libreforge.filters.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.util.NamespacedKeyUtils import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.triggers.TriggerData -import org.bukkit.entity.Boss import org.bukkit.entity.Creature -import org.bukkit.entity.ElderGuardian import org.bukkit.entity.Monster -import org.bukkit.persistence.PersistentDataType object FilterIsPassive : Filter("is_passive") { override fun getValue(config: Config, data: TriggerData?, key: String): Boolean { diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityAbovePercent.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityAbovePercent.kt index fa05a78a2..ef0e65e3a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityAbovePercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityAbovePercent.kt @@ -4,10 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.TriggerData import org.bukkit.inventory.meta.Damageable -import java.util.DoubleSummaryStatistics object FilterItemDurabilityAbovePercent : Filter("item_durability_above_percent") { override fun getValue(config: Config, data: TriggerData?, key: String): Double { diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityBelowPercent.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityBelowPercent.kt index 2d70d152f..bafa98fce 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityBelowPercent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterItemDurabilityBelowPercent.kt @@ -4,10 +4,8 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.getDoubleFromExpression -import com.willfp.libreforge.getIntFromExpression import com.willfp.libreforge.triggers.TriggerData import org.bukkit.inventory.meta.Damageable -import java.util.DoubleSummaryStatistics object FilterItemDurabilityBelowPercent : Filter("item_durability_below_percent") { override fun getValue(config: Config, data: TriggerData?, key: String): Double { diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterValueAbove.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterValueAbove.kt index 8c019c1a4..a3b994212 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterValueAbove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterValueAbove.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge.filters.impl import com.willfp.eco.core.config.interfaces.Config -import com.willfp.eco.util.containsIgnoreCase import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.filters.Filter import com.willfp.libreforge.getDoubleFromExpression diff --git a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt index 2f529defb..8665e5eda 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/filters/impl/FilterVictimConditions.kt @@ -5,7 +5,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.filters.Filter -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.TriggerData object FilterVictimConditions : Filter>("victim_conditions") { @@ -16,7 +16,7 @@ object FilterVictimConditions : Filter>("victi override fun isMet(data: TriggerData, value: Collection, compileData: ConditionList): Boolean { val victim = data.victim ?: return false - return compileData.areMet(EntityDispatcher(victim), data.holder) + return compileData.areMet(victim.toDispatcher(), data.holder) } override fun makeCompileData(config: Config, context: ViolationContext, values: Collection): ConditionList { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt index 26e8657f5..ef0fa2699 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ArgumentManaCost.kt @@ -7,11 +7,11 @@ import com.willfp.eco.util.StringUtils import com.willfp.libreforge.ConfigurableElement import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.effects.arguments.EffectArgument +import com.willfp.libreforge.get import com.willfp.libreforge.getDoubleFromExpression import com.willfp.libreforge.plugin import com.willfp.libreforge.toFriendlyPointName import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.get import org.bukkit.Sound import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt index 315612821..d23964a84 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/ConditionHasMana.kt @@ -3,13 +3,13 @@ package com.willfp.libreforge.integrations.aureliumskills.impl import com.archyx.aureliumskills.api.AureliumAPI import com.archyx.aureliumskills.api.event.ManaRegenerateEvent import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -22,8 +22,7 @@ object ConditionHasMana : Condition("has_mana") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: ManaRegenerateEvent) { - val dispatcher = EntityDispatcher(event.player) - dispatcher.updateEffects() + event.player.toDispatcher().updateEffects() } override fun isMet( diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt index 1c4e28b6e..cb97263f4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectAddStat.kt @@ -3,14 +3,14 @@ package com.willfp.libreforge.integrations.aureliumskills.impl import com.archyx.aureliumskills.api.AureliumAPI import com.archyx.aureliumskills.stats.Stats import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.plugin -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.plugin import org.bukkit.entity.Player object EffectAddStat : Effect("add_stat") { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt index e971fffd3..a558eaf22 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/aureliumskills/impl/EffectSkillXpMultiplier.kt @@ -4,7 +4,7 @@ import com.archyx.aureliumskills.api.event.XpGainEvent import com.archyx.aureliumskills.skills.Skill import com.archyx.aureliumskills.skills.Skills import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multiplier") { @@ -22,7 +22,7 @@ object EffectSkillXpMultiplier : MultiMultiplierEffect("skill_xp_multipli fun handle(event: XpGainEvent) { val player = event.player - val multiplier = getMultiplier(EntityDispatcher(player), event.skill) + val multiplier = getMultiplier(player.toDispatcher(), event.skill) event.amount *= multiplier } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt index 547d49804..59c2456b3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerLeftClickNPC.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerLeftClickNPC : Trigger("left_click_npc") { val player = event.clicker ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt index 91cd65e39..7af25a658 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/citizens/impl/TriggerRightClickNPC.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.citizens.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerRightClickNPC : Trigger("right_click_npc") { val player = event.clicker ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt index f98390f1e..5102caea1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsMoneyMultiplier.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsPaymentEvent import com.gamingmesh.jobs.container.CurrencyType import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -12,7 +12,7 @@ object EffectJobsMoneyMultiplier : MultiplierEffect("jobs_money_multiplier") { fun handle(event: JobsPaymentEvent) { val player = event.player as? Player ?: return - val multiplier = getMultiplier(EntityDispatcher(player)) + val multiplier = getMultiplier(player.toDispatcher()) var money = event.payment[CurrencyType.MONEY] ?: return money *= multiplier diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt index 6620f236b..e2a7ce320 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/EffectJobsXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gamingmesh.jobs.Jobs import com.gamingmesh.jobs.api.JobsExpGainEvent import com.gamingmesh.jobs.container.Job import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -23,6 +23,6 @@ object EffectJobsXpMultiplier : MultiMultiplierEffect("jobs_xp_multiplier") fun handle(event: JobsExpGainEvent) { val player = event.player as? Player ?: return - event.exp *= getMultiplier(EntityDispatcher(player), event.job) + event.exp *= getMultiplier(player.toDispatcher(), event.job) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt index c71524a53..5d659508a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/jobs/impl/TriggerJobsLevelUp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.jobs.impl import com.gamingmesh.jobs.api.JobsLevelUpEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerJobsLevelUp : Trigger("jobs_level_up") { val player = event.player.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt index 04d681237..e9251705f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/mcmmo/impl/EffectMcMMOXpMultiplier.kt @@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent import com.gmail.nossr50.mcMMO import com.willfp.libreforge.effects.templates.MultiMultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_xp_multiplier") { @@ -22,6 +22,6 @@ object EffectMcMMOXpMultiplier : MultiMultiplierEffect("mcmmo_ fun handle(event: McMMOPlayerXpGainEvent) { val player = event.player - event.rawXpGained *= getMultiplier(EntityDispatcher(player), event.skill).toFloat() + event.rawXpGained *= getMultiplier(player.toDispatcher(), event.skill).toFloat() } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt index 3237e5195..aa8a7937d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInBubble.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt index 9fd65a74a..b96fa7a32 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInLava.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt index f8c904797..788cdd23c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/ConditionInRain.kt @@ -1,10 +1,10 @@ package com.willfp.libreforge.integrations.paper.impl import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import org.bukkit.entity.Entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt index 84e85e20a..e24f8ab49 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectDropPickupItem.kt @@ -12,8 +12,8 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.ChainExecutors import com.willfp.libreforge.plugin +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.ChatColor @@ -49,7 +49,7 @@ object EffectDropPickupItem : Effect("drop_pickup_item") { val meta = Meta( chain, - data.dispatch(EntityDispatcher(player)), + data.dispatch(player.toDispatcher()), glowColor?.let { TeamUtils.fromChatColor(it) } ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt index 81b34bf04..1aa1c1166 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/EffectElytraBoostSaveChance.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent import com.willfp.libreforge.effects.templates.ChanceMultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_chance") { @@ -10,7 +10,7 @@ object EffectElytraBoostSaveChance : ChanceMultiplierEffect("elytra_boost_save_c fun handle(event: PlayerElytraBoostEvent) { val player = event.player - if (passesChance(EntityDispatcher(player))) { + if (passesChance(player.toDispatcher())) { event.setShouldConsume(false) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt index b8d80d372..1858962ee 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerBeaconEffect.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.block.BeaconEffectEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerBeaconEffect : Trigger("beacon_effect") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt index 5bc6964e2..227f9b817 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerElytraBoost.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.paper.impl import com.destroystokyo.paper.event.player.PlayerElytraBoostEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerElytraBoost : Trigger("elytra_boost") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt index 72a9c07f9..b9bea5570 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerSwing.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerSwing : Trigger("swing") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt index 43b512731..abbec937f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/paper/impl/TriggerVillagerTrade.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.paper.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerVillagerTrade : Trigger("villager_trade") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = event.villager, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt index b447d947b..8611234da 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoCollect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerScytherAutoCollect : Trigger("scyther_auto_collect") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutocollectEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt index 1d445346b..f274c376c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/scyther/impl/TriggerScytherAutoSell.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.scyther.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerScytherAutoSell : Trigger("scyther_auto_sell") { @EventHandler(ignoreCancelled = true) fun handle(event: ScytherAutosellEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, block = event.block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt index 14540edc6..b56919673 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/TMMobcoinsIntegration.kt @@ -3,8 +3,6 @@ package com.willfp.libreforge.integrations.tmmobcoins import com.willfp.eco.core.EcoPlugin import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.integrations.LoadableIntegration -import com.willfp.libreforge.integrations.jobs.impl.EffectJobsMoneyMultiplier -import com.willfp.libreforge.integrations.jobs.impl.EffectJobsXpMultiplier import com.willfp.libreforge.integrations.tmmobcoins.impl.EffectMobCoinsMultiplier object TMMobcoinsIntegration : LoadableIntegration { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt index b5d1e571a..a9c45bf2b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/tmmobcoins/impl/EffectMobCoinsMultiplier.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.integrations.tmmobcoins.impl import com.willfp.libreforge.effects.templates.MultiplierEffect -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import net.devtm.tmmobcoins.API.MobCoinReceiveEvent import org.bukkit.event.EventHandler @@ -10,6 +10,6 @@ object EffectMobCoinsMultiplier : MultiplierEffect("mob_coins_multiplier") { fun handle(event: MobCoinReceiveEvent) { val player = event.player - event.setDropAmount(event.obtainedAmount * getMultiplier(EntityDispatcher(player))) + event.setDropAmount(event.obtainedAmount * getMultiplier(player.toDispatcher())) } } diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt index 5f448509d..8030c1708 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/vault/impl/EffectGivePermission.kt @@ -2,12 +2,12 @@ package com.willfp.libreforge.integrations.vault.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.map.listMap +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.effects.Identifiers -import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get import net.milkbowl.vault.permission.Permission import org.bukkit.entity.Player diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt index eba4d2a09..716a5743a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/ConditionInRegion.kt @@ -4,11 +4,11 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldedit.math.BlockVector3 import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.config.interfaces.Config +import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.arguments import com.willfp.libreforge.conditions.Condition -import com.willfp.libreforge.Dispatcher object ConditionInRegion : Condition("in_region") { override val arguments = arguments { diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt index 26b1016a6..93eccbb17 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerEnterRegion.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.integrations.worldguard.impl import com.sk89q.worldedit.bukkit.BukkitAdapter import com.sk89q.worldguard.WorldGuard import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -55,7 +55,7 @@ object TriggerEnterRegion : Trigger("enter_region") { for (region in entered) { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt index bcf9d0e77..8c5fb0eee 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/integrations/worldguard/impl/TriggerLeaveRegion.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.integrations.worldguard.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -15,7 +15,7 @@ object TriggerLeaveRegion : Trigger("leave_region") { fun dispatch(player: Player, event: RegionEvent) { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt index 678520214..014d06b32 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/levels/LevelType.kt @@ -13,8 +13,8 @@ import com.willfp.libreforge.NamedValue import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.levels.event.ItemLevelUpEvent +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.DispatchedTrigger -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.impl.TriggerLevelUpItem import org.bukkit.Bukkit @@ -64,7 +64,7 @@ class LevelType( levelUpEffects?.trigger( DispatchedTrigger( - EntityDispatcher(player), + player.toDispatcher(), TriggerLevelUpItem, TriggerData( player = player, diff --git a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToBlock.kt index 6b37e1b07..a5f361652 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToBlock.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.mutators.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.mutators.Mutator -import com.willfp.libreforge.mutators.TriggerParameterTransformer import com.willfp.libreforge.mutators.parameterTransformers import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToPlayer.kt index 0ce870d2a..1ed942188 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorLocationToPlayer.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.mutators.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.mutators.Mutator -import com.willfp.libreforge.mutators.TriggerParameterTransformer import com.willfp.libreforge.mutators.parameterTransformers import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter diff --git a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorVictimToOwner.kt b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorVictimToOwner.kt index d4bd8d843..dbf0931fc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorVictimToOwner.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/mutators/impl/MutatorVictimToOwner.kt @@ -3,9 +3,7 @@ package com.willfp.libreforge.mutators.impl import com.willfp.eco.core.config.interfaces.Config import com.willfp.libreforge.NoCompileData import com.willfp.libreforge.mutators.Mutator -import com.willfp.libreforge.mutators.parameterTransformers import com.willfp.libreforge.triggers.TriggerData -import com.willfp.libreforge.triggers.TriggerParameter import org.bukkit.entity.LivingEntity import org.bukkit.entity.Tameable diff --git a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt index e74041662..e27bc5873 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/placeholders/impl/ConditionalCustomPlaceholder.kt @@ -6,12 +6,13 @@ import com.willfp.eco.core.placeholder.RegistrablePlaceholder import com.willfp.eco.core.placeholder.context.PlaceholderContext import com.willfp.eco.core.placeholder.templates.SimplePlaceholder import com.willfp.libreforge.BlankHolder +import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.ConditionList import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.placeholders.CustomPlaceholder -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.inventory.ItemStack class ConditionalCustomPlaceholder( @@ -40,7 +41,7 @@ class ConditionalCustomPlaceholder( val holder = BlankItemHolder(ctx.itemStack) val value = values - .firstOrNull { it.conditions.areMet(EntityDispatcher(player), holder) } + .firstOrNull { it.conditions.areMet(player.toDispatcher(), holder) } ?.expr ?: return defaultExpr?.let { parseValue(it, ctx) } return parseValue(value, ctx) diff --git a/core/src/main/kotlin/com/willfp/libreforge/slot/SlotTypes.kt b/core/src/main/kotlin/com/willfp/libreforge/slot/SlotTypes.kt index b1d23a7ff..e237da2fc 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/slot/SlotTypes.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/slot/SlotTypes.kt @@ -1,16 +1,16 @@ package com.willfp.libreforge.slot import com.willfp.eco.core.registry.Registry +import com.willfp.libreforge.slot.impl.NumericSlotType import com.willfp.libreforge.slot.impl.SlotTypeAny import com.willfp.libreforge.slot.impl.SlotTypeArmor import com.willfp.libreforge.slot.impl.SlotTypeBoots import com.willfp.libreforge.slot.impl.SlotTypeChestplate -import com.willfp.libreforge.slot.impl.SlotTypeMainhand +import com.willfp.libreforge.slot.impl.SlotTypeHand import com.willfp.libreforge.slot.impl.SlotTypeHands import com.willfp.libreforge.slot.impl.SlotTypeHelmet import com.willfp.libreforge.slot.impl.SlotTypeLeggings -import com.willfp.libreforge.slot.impl.NumericSlotType -import com.willfp.libreforge.slot.impl.SlotTypeHand +import com.willfp.libreforge.slot.impl.SlotTypeMainhand import com.willfp.libreforge.slot.impl.SlotTypeOffhand object SlotTypes : Registry() { diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt index 5fe0c6b8a..e00cb36d0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTrigger.kt @@ -3,8 +3,8 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.placeholder.InjectablePlaceholder import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.NamedValue -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.placeholders.TriggerPlaceholders import org.bukkit.entity.Player @@ -20,7 +20,7 @@ data class DispatchedTrigger( @Deprecated( "Use dispatcher instead", - ReplaceWith("dispatcher.get()"), + ReplaceWith("toDispatcher().get()"), DeprecationLevel.ERROR ) val player: Player? @@ -28,14 +28,14 @@ data class DispatchedTrigger( @Deprecated( "DispatchedTrigger should be constructed with a Dispatcher", - ReplaceWith("DispatchedTrigger(dispatcher, trigger, data)"), + ReplaceWith("DispatchedTrigger(player.toDispatcher(), trigger, data)"), DeprecationLevel.ERROR ) constructor( player: Player, trigger: Trigger, data: TriggerData, - ) : this(EntityDispatcher(player), trigger, data) + ) : this(player.toDispatcher(), trigger, data) fun addPlaceholder(placeholder: NamedValue) { _placeholders += placeholder diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt index 1a5a262e4..a073aae6e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/DispatchedTriggerFactory.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.map.listMap import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import java.util.UUID @@ -24,7 +24,7 @@ class DispatchedTriggerFactory( DeprecationLevel.ERROR ) fun create(player: Player, trigger: Trigger, data: TriggerData): DispatchedTrigger? { - return create(EntityDispatcher(player), trigger, data) + return create(player.toDispatcher(), trigger, data) } fun create(dispatcher: Dispatcher<*>, trigger: Trigger, data: TriggerData): DispatchedTrigger? { diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt index 07fdbf822..ec3433afd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/Trigger.kt @@ -2,19 +2,16 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.registry.KRegistrable import com.willfp.libreforge.Dispatcher -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.ProvidedEffectBlock import com.willfp.libreforge.ProvidedEffectBlocks import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.counters.bind.BoundCounters import com.willfp.libreforge.counters.bind.BoundCounters.bindings import com.willfp.libreforge.generatePlaceholders -import com.willfp.libreforge.get import com.willfp.libreforge.getProvidedActiveEffects -import com.willfp.libreforge.ifType -import com.willfp.libreforge.isType import com.willfp.libreforge.plugin import com.willfp.libreforge.providedActiveEffects +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.event.TriggerDispatchEvent import org.bukkit.Bukkit import org.bukkit.entity.Player @@ -43,14 +40,14 @@ abstract class Trigger( @Deprecated( "Use dispatch(dispatcher, data, forceHolders) instead", - ReplaceWith("dispatch(dispatcher, data, forceHolders)"), + ReplaceWith("dispatch(player.toDispatcher(), data, forceHolders)"), DeprecationLevel.ERROR ) fun dispatch( player: Player, data: TriggerData, forceHolders: Collection? = null - ) = dispatch(EntityDispatcher(player), data, forceHolders) + ) = dispatch(player.toDispatcher(), data, forceHolders) /** * Dispatch the trigger. diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt index c7486b4ba..32fc944bf 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/TriggerData.kt @@ -3,9 +3,9 @@ package com.willfp.libreforge.triggers import com.willfp.eco.core.items.HashedItem import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.EmptyProvidedHolder -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.getProvider +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.impl.TriggerBlank import org.bukkit.Location import org.bukkit.block.Block @@ -53,11 +53,11 @@ data class TriggerData( */ @Deprecated( "Use dispatch(dispatcher) instead", - ReplaceWith("dispatch(dispatcher)"), + ReplaceWith("dispatch(player.toDispatcher())"), DeprecationLevel.ERROR ) fun dispatch(player: Player) = - dispatch(EntityDispatcher(player)) + dispatch(player.toDispatcher()) /** * Turn into a dispatched trigger for a [dispatcher]. diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt index e99d4ae0e..72e8b067b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/event/TriggerDispatchEvent.kt @@ -1,8 +1,8 @@ package com.willfp.libreforge.triggers.event -import com.willfp.libreforge.triggers.DispatchedTrigger import com.willfp.libreforge.Dispatcher import com.willfp.libreforge.get +import com.willfp.libreforge.triggers.DispatchedTrigger import org.bukkit.entity.Player import org.bukkit.event.Cancellable import org.bukkit.event.Event @@ -16,7 +16,7 @@ class TriggerDispatchEvent( @Deprecated( "Use dispatcher instead", - ReplaceWith("dispatcher.get()"), + ReplaceWith("toDispatcher().get()"), DeprecationLevel.ERROR ) val player: Player? diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt index 09f54b6c0..e912ab310 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerAltClick.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -131,7 +131,7 @@ object TriggerAltClick : Trigger("alt_click") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt index 5652ce8e9..28d25da3f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBite.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerBite : Trigger("bite") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt index 866cdf53a..5656e6746 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBlockItemDrop.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -49,7 +49,7 @@ object TriggerBlockItemDrop : Trigger("block_item_drop") { val editableEvent = EditableBlockDropEvent(event) this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, block = BrokenBlock(block, event.blockState.type), // Fixes the type always being AIR diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt index 1a18c3594..a2e32cf12 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBowAttack.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -45,7 +45,7 @@ object TriggerBowAttack : Trigger("bow_attack") { } this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt index db614b036..c1bf684ae 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBreed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerBreed : Trigger("breed") { val player = event.breeder as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt index 667d9b972..de2ca41e5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrew.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -53,7 +53,7 @@ object TriggerBrew : Trigger("brew") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt index 2792646e6..c760a2268 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerBrewIngredient.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.gui.player import com.willfp.eco.core.recipe.parts.EmptyTestableItem import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -49,7 +49,7 @@ object TriggerBrewIngredient : Trigger("brew_ingredient") { .count { !EmptyTestableItem().matches(it) } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = event.contents.ingredient, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt index 90fa456d1..036b521a6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCastRod.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCastRod : Trigger("cast_rod") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt index ff5994fa9..1d358462d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchEntity.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +28,7 @@ object TriggerCatchEntity : Trigger("catch_entity") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.caught?.location ?: player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt index 3815c0a4e..60e577bff 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFish.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCatchFish : Trigger("catch_fish") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt index 8b50f3a0e..1f245ae4d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCatchFishFail.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerCatchFishFail : Trigger("catch_fish_fail") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt index 317edf9d4..bf521ca6d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeArmor.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.ArmorChangeEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerChangeArmor : Trigger("change_armor") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt index 8685e017c..c46441513 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerChangeChunk : Trigger("change_chunk") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt index 4afa5acee..dc0b50096 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeWorld.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerChangeWorld : Trigger("change_world") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt index 45a812f82..183acbee7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickBlock.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -40,7 +40,7 @@ object TriggerClickBlock : Trigger("click_block") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = block.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt index e0b55f809..9b534f840 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerClickEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerClickEntity : Trigger("click_entity") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt index 61222ef13..6d7ac020c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerConsume.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerConsume : Trigger("consume") { fun handle(event: PlayerItemConsumeEvent) { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt index ee64bf914..6fdce3700 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerCraft.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -92,7 +92,7 @@ object TriggerCraft : Trigger("craft") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt index 7fb7f2997..adc0dd5e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDamageItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerDamageItem : Trigger("damage_item") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt index f3ef1625b..6fc9ec40e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeath.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerDeath : Trigger("death") { val player = event.entity this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt index c57acefc2..8a33d1017 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDeployElytra.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerDeployElytra : Trigger("deploy_elytra") { val player = event.entity as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt index d782d433e..4b8c8da1e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDisable.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderDisableEvent -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt index aa583fb40..44d708776 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDrink.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -32,7 +32,7 @@ object TriggerDrink : Trigger("drink") { } val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt index 0f0fbd493..eb4998606 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerDropItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerDropItem : Trigger("drop_item") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = event.itemDrop.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt index c5355c9dd..8193b4cd2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEmptyBucket.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerEmptyBucket : Trigger("empty_bucket") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt index e1df273bf..d5c461a1d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnable.kt @@ -1,7 +1,6 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.HolderEnableEvent -import com.willfp.libreforge.EntityDispatcher import com.willfp.libreforge.get import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt index 433873ec9..c4e736901 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnchantItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerEnchantItem : Trigger("enchant_item") { val item = event.item this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt index 5eaf59e8e..6db79b555 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEnterBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerEnterBed : Trigger("enter_bed") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt index e1e4c5721..58de238f0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityItemDrop.kt @@ -5,7 +5,7 @@ import com.willfp.eco.core.drops.DropQueue import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer import com.willfp.libreforge.filterNotEmpty -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -36,7 +36,7 @@ object TriggerEntityItemDrop : Trigger("entity_item_drop") { val editableEvent = EditableEntityDropEvent(event.deathEvent) this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt index 5d2b11fd0..c0bd4f3b8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerEntityTarget.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerEntityTarget : Trigger("entity_target") { val entity = event.entity as? LivingEntity ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = entity diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt index f3ee34084..da35c6cd6 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFallDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -28,7 +28,7 @@ object TriggerFallDamage : Trigger("fall_damage") { } this.dispatch( - EntityDispatcher(victim), + victim.toDispatcher(), TriggerData( player = victim, location = victim.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt index b8f1cda9f..9970caef4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerFillBucket.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerFillBucket : Trigger("fill_bucket") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt index aca748556..a6c3080ba 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerGainHunger : Trigger("gain_hunger") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt index b74f5a320..aa4edc431 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGainXp.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.NaturalExpGainEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerGainXp : Trigger("gain_xp") { val player = event.expChangeEvent.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event.expChangeEvent, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt index 4abff62a8..c05cd2792 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupCustom.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -26,7 +26,7 @@ object TriggerGroupCustom : TriggerGroup("custom") { fun dispatch(player: Player, data: TriggerData) { super.dispatch( - EntityDispatcher(player), + player.toDispatcher(), data, null ) diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt index a2b1d65f0..622e84e7e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupGlobalStatic.kt @@ -6,7 +6,6 @@ import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup import com.willfp.libreforge.triggers.TriggerParameter -import org.bukkit.Bukkit object TriggerGroupGlobalStatic : TriggerGroup("global_static") { private val registry = mutableMapOf() diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt index 6838686e1..45feeff82 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerGroupStatic.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerGroup @@ -52,7 +52,7 @@ object TriggerGroupStatic : TriggerGroup("static") { } else null this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt index a9006e2b9..721bfa272 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeadshot.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -31,7 +31,7 @@ object TriggerHeadshot : Trigger("headshot") { } this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt index a9d03c69f..10f8be9c3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHeal.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerHeal : Trigger("heal") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt index 230d81596..a5dff7610 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHoldItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerHoldItem : Trigger("hold_item") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt index cdc74cee1..731993689 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerHookInGround.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerHookInGround : Trigger("hook_in_ground") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt index 0e6368dae..92f2338d2 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerItemBreak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerItemBreak : Trigger("item_break") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt index d7df4dc9a..02f7f9e2c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJoin.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerJoin : Trigger("join") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerJoinEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt index f564a4c34..e588364d3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerJump.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.PlayerJumpEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerJump : Trigger("jump") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt index a15f0e120..a375aaa50 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerKill.kt @@ -2,7 +2,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.events.EntityDeathByEntityEvent import com.willfp.eco.util.tryAsPlayer -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerKill : Trigger("kill") { val victim = event.victim this.dispatch( - EntityDispatcher(killer), + killer.toDispatcher(), TriggerData( player = killer, victim = victim, @@ -38,7 +38,7 @@ object TriggerKill : Trigger("kill") { fun force(player: Player, victim: LivingEntity) { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt index 7d9b24c6b..e62824760 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeashEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerLeashEntity : Trigger("leash_entity") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.entity.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt index 8104f8b9c..d61f23e7e 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeave.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerLeave : Trigger("leave") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerQuitEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt index 39a815f87..5e42f8ce0 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLeaveBed.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -18,7 +18,7 @@ object TriggerLeaveBed : Trigger("leave_bed") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt index d0703ad5d..2b4eba30d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.levels.event.ItemLevelUpEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerLevelUpItem : Trigger("level_up_item") { @EventHandler fun handle(event: ItemLevelUpEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, item = event.item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt index 9908d849b..dd044fab3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLevelUpXp.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerLevelUpXp : Trigger("level_up_xp") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, value = event.newLevel.toDouble() diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt index 458a2cfd4..2246a046f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLoseHunger.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerLoseHunger : Trigger("lose_hunger") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt index e11e6e999..94404204c 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerLosePotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -28,7 +28,7 @@ object TriggerLosePotionEffect : Trigger("lose_potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt index 469996349..28b61cc62 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMeleeAttack.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -29,7 +29,7 @@ object TriggerMeleeAttack : Trigger("melee_attack") { } this.dispatch( - EntityDispatcher(attacker), + attacker.toDispatcher(), TriggerData( player = attacker, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt index 14202fb41..014343a21 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerMineBlock : Trigger("mine_block") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt index d3fdc477f..b872656e1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMineBlockProgress.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -22,7 +22,7 @@ object TriggerMineBlockProgress : Trigger("mine_block_progress") { val block = event.block this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index a22f17a36..bb8fa0659 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -34,7 +34,7 @@ object TriggerMove : Trigger("move") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt index cef67491f..b5ae5456d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPickUpItem.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerPickUpItem : Trigger("pick_up_item") { val player = event.entity as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = event.item.itemStack, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt index c1783f7da..ffda26bdd 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPlaceBlock.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.antigrief.AntigriefManager -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -27,7 +27,7 @@ object TriggerPlaceBlock : Trigger("place_block") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, block = block, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt index 8c6aee5bc..5e0115a6d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerPotionEffect.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -24,7 +24,7 @@ object TriggerPotionEffect : Trigger("potion_effect") { val player = event.entity as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt index f7327068d..e3fffd40b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileHit.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -32,7 +32,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { } this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, projectile = projectile, @@ -51,7 +51,7 @@ object TriggerProjectileHit : Trigger("projectile_hit") { val player = arrow.shooter as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt index 428105e99..35644b39d 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerProjectileLaunch.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerProjectileLaunch : Trigger("projectile_launch") { } this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, projectile = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt index a78639b60..ea5b550b7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerReelIn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerReelIn : Trigger("reel_in") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.hook.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt index 25ac2d5ab..c4336cec9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRespawn.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -16,7 +16,7 @@ object TriggerRespawn : Trigger("respawn") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerRespawnEvent) { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, location = event.player.location diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt index 6dadf869e..60e2019a3 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerRunCommand.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerRunCommand : Trigger("run_command") { plugin.scheduler.run { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt index 4b1403167..24dd3412b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSellItem.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.integrations.shop.ShopSellEvent -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerSellItem : Trigger("sell_item") { val item = event.item this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt index fa1044a1b..861067bd8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSendMessage.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerSendMessage : Trigger("send_message") { plugin.scheduler.run { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt index face3d3b5..d722ad313 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShearEntity.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -25,7 +25,7 @@ object TriggerShearEntity : Trigger("shear_entity") { } this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, victim = entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt index 6fd57d90a..dce31c0f8 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShieldBlock.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -36,7 +36,7 @@ object TriggerShieldBlock : Trigger("shield_block") { } this.dispatch( - EntityDispatcher(victim), + victim.toDispatcher(), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt index f419822cc..13fdbfca7 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerShootBow.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -26,7 +26,7 @@ object TriggerShootBow : Trigger("shoot_bow") { } this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, projectile = event.projectile as? Projectile, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt index efedd48be..b30029888 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSmelt.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerSmelt : Trigger("smelt") { val item = event.result this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, item = item, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt index f4169ca27..88a07ff01 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerSwapHands.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -23,7 +23,7 @@ object TriggerSwapHands : Trigger("swap_hands") { } this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt index 9703ace18..027a26379 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeDamage.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.eco.core.Prerequisite -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -39,7 +39,7 @@ object TriggerTakeDamage : Trigger("take_damage") { } this.dispatch( - EntityDispatcher(victim), + victim.toDispatcher(), TriggerData( player = victim, event = event, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt index ed7b6295d..675691610 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTakeEntityDamage.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -37,7 +37,7 @@ object TriggerTakeEntityDamage : Trigger("take_entity_damage") { } this.dispatch( - EntityDispatcher(victim), + victim.toDispatcher(), TriggerData( player = victim, victim = attacker, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt index 600ad1fa8..026e27438 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTameAnimal.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -21,7 +21,7 @@ object TriggerTameAnimal : Trigger("tame_animal") { val player = event.owner as? Player ?: return this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, victim = event.entity, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt index b6a3baba6..379bd6aed 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTeleport.kt @@ -1,7 +1,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -19,7 +19,7 @@ object TriggerTeleport : Trigger("teleport") { fun handle(event: PlayerTeleportEvent) { plugin.scheduler.run { this.dispatch( - EntityDispatcher(event.player), + event.player.toDispatcher(), TriggerData( player = event.player, location = event.to, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt index 736813e50..5fdcbcdd1 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleFlight.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleFlight : Trigger("toggle_flight") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt index ffd71d62e..44a89aabe 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSneak.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleSneak : Trigger("toggle_sneak") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt index 8754b9260..1af79ae80 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerToggleSprint.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -20,7 +20,7 @@ object TriggerToggleSprint : Trigger("toggle_sprint") { val player = event.player this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt index 591865f65..dd4457d4f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerTridentAttack.kt @@ -3,7 +3,7 @@ package com.willfp.libreforge.triggers.impl import com.willfp.libreforge.ProvidedHolder import com.willfp.libreforge.holders import com.willfp.libreforge.plugin -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -38,9 +38,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { trident.setMetadata( META_KEY, - plugin.metadataValueFactory.create( - EntityDispatcher(shooter).holders - ) + plugin.metadataValueFactory.create(shooter.toDispatcher().holders) ) } @@ -53,7 +51,7 @@ object TriggerTridentAttack : Trigger("trident_attack") { @Suppress("UNCHECKED_CAST") this.dispatch( - EntityDispatcher(shooter), + shooter.toDispatcher(), TriggerData( player = shooter, victim = victim, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt index c528d7775..24456999b 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerWinRaid.kt @@ -1,6 +1,6 @@ package com.willfp.libreforge.triggers.impl -import com.willfp.libreforge.EntityDispatcher +import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter @@ -17,7 +17,7 @@ object TriggerWinRaid : Trigger("win_raid") { fun handle(event: RaidFinishEvent) { for (player in event.winners) { this.dispatch( - EntityDispatcher(player), + player.toDispatcher(), TriggerData( player = player, location = event.raid.location, diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/placeholders/impl/TriggerPlaceholderPlayer.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/placeholders/impl/TriggerPlaceholderPlayer.kt index 84f3d86e4..7071bfcc9 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/placeholders/impl/TriggerPlaceholderPlayer.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/placeholders/impl/TriggerPlaceholderPlayer.kt @@ -3,7 +3,6 @@ package com.willfp.libreforge.triggers.placeholders.impl import com.willfp.libreforge.NamedValue import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.placeholders.TriggerPlaceholder -import org.bukkit.attribute.Attribute object TriggerPlaceholderPlayer : TriggerPlaceholder("player") { override fun createPlaceholders(data: TriggerData): Collection { From 052bead29e3bc5cfe40d87e6eb1d6c1378672429 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 21:44:23 +0000 Subject: [PATCH 10/11] Various adjustments and improvements --- .../com/willfp/libreforge/HolderProvider.kt | 15 +++++++++++++-- .../willfp/libreforge/LibreforgeSpigotPlugin.kt | 5 +++++ .../libreforge/effects/impl/EffectBroadcast.kt | 9 +++------ .../triggers/impl/TriggerChangeChunk.kt | 15 ++++++++------- .../libreforge/triggers/impl/TriggerMove.kt | 17 +++++++++-------- 5 files changed, 38 insertions(+), 23 deletions(-) diff --git a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt index 46d0b0338..6d043c2b4 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/HolderProvider.kt @@ -152,8 +152,8 @@ fun registerRefreshFunction(function: (Dispatcher<*>) -> Unit) { } @Deprecated( - "Use registerRefreshFunction instead", - ReplaceWith("registerRefreshFunction(function)"), + "Use registerSpecificRefreshFunction instead", + ReplaceWith("registerSpecificRefreshFunction(function)"), DeprecationLevel.ERROR ) fun registerPlayerRefreshFunction(function: (Player) -> Unit) { @@ -164,6 +164,17 @@ fun registerPlayerRefreshFunction(function: (Player) -> Unit) { } } +/** + * Register a function to be called when a dispatcher's holders are refreshed for a specific dispatcher. + */ +inline fun registerSpecificRefreshFunction(crossinline function: (T) -> Unit) { + registerRefreshFunction { + it.get()?.let { t -> + function(t) + } + } +} + /** * Update holders, effects, and call refresh functions. */ diff --git a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt index b86d768e5..9e0ae6364 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/LibreforgeSpigotPlugin.kt @@ -135,6 +135,11 @@ class LibreforgeSpigotPlugin : EcoPlugin() { } currentOffset += 3 } + + // Poll for changes in global holders + this.scheduler.runTimer(25, 20) { + GlobalDispatcher.refreshHolders() + } } override fun loadListeners(): List { diff --git a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBroadcast.kt b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBroadcast.kt index 5cad3c5de..efa580a59 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBroadcast.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/effects/impl/EffectBroadcast.kt @@ -8,22 +8,19 @@ import com.willfp.libreforge.effects.Effect import com.willfp.libreforge.toPlaceholderContext import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter +import net.tmmobcoins.lib.CBA.CBAMethods.name import org.bukkit.Bukkit object EffectBroadcast : Effect("broadcast") { - override val parameters = setOf( - TriggerParameter.PLAYER - ) + override val isPermanent = false override val arguments = arguments { require("message", "You must specify the message to send!") } override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean { - val player = data.player ?: return false - val message = config.getString("message") - .replace("%player%", player.name) + .replace("%player%", data.player?.name ?: "%player%") .formatEco(config.toPlaceholderContext(data)) @Suppress("DEPRECATION") diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt index c46441513..69dc98d16 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerChangeChunk.kt @@ -4,8 +4,9 @@ import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter +import io.papermc.paper.event.entity.EntityMoveEvent +import org.bukkit.entity.Player import org.bukkit.event.EventHandler -import org.bukkit.event.player.PlayerMoveEvent object TriggerChangeChunk : Trigger("change_chunk") { override val parameters = setOf( @@ -17,8 +18,8 @@ object TriggerChangeChunk : Trigger("change_chunk") { ) @EventHandler(ignoreCancelled = true) - fun handle(event: PlayerMoveEvent) { - val player = event.player + fun handle(event: EntityMoveEvent) { + val entity = event.entity if (event.to.chunk.x != event.from.chunk.x || event.to.chunk.z != event.from.chunk.z @@ -27,13 +28,13 @@ object TriggerChangeChunk : Trigger("change_chunk") { } this.dispatch( - player.toDispatcher(), + entity.toDispatcher(), TriggerData( - player = player, + player = entity as? Player, location = event.to, - velocity = player.velocity, + velocity = entity.velocity, event = event, - item = player.inventory.itemInMainHand + item = entity.equipment?.itemInMainHand ) ) } diff --git a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt index bb8fa0659..8c290cfe5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/triggers/impl/TriggerMove.kt @@ -5,8 +5,9 @@ import com.willfp.libreforge.toDispatcher import com.willfp.libreforge.triggers.Trigger import com.willfp.libreforge.triggers.TriggerData import com.willfp.libreforge.triggers.TriggerParameter +import io.papermc.paper.event.entity.EntityMoveEvent +import org.bukkit.entity.Player import org.bukkit.event.EventHandler -import org.bukkit.event.player.PlayerMoveEvent object TriggerMove : Trigger("move") { override val parameters = setOf( @@ -18,8 +19,8 @@ object TriggerMove : Trigger("move") { ) @EventHandler(ignoreCancelled = true) - fun handle(event: PlayerMoveEvent) { - val player = event.player + fun handle(event: EntityMoveEvent) { + val entity = event.entity if (Prerequisite.HAS_PAPER.isMet) { if (!event.hasChangedBlock()) { @@ -34,13 +35,13 @@ object TriggerMove : Trigger("move") { } this.dispatch( - player.toDispatcher(), + entity.toDispatcher(), TriggerData( - player = player, - location = player.location, - velocity = player.velocity, + player = entity as? Player, + location = entity.location, + velocity = entity.velocity, event = event, - item = player.inventory.itemInMainHand, + item = entity.equipment?.itemInMainHand, value = distance ) ) From a7228fef31e9e641e1b727558fc6045c4182d28f Mon Sep 17 00:00:00 2001 From: Auxilor Date: Tue, 21 Nov 2023 21:47:41 +0000 Subject: [PATCH 11/11] Added BlockDispatcher and LocationDispatcher --- .../com/willfp/libreforge/Dispatcher.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt index c81e15a3c..4b371a98f 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/Dispatcher.kt @@ -1,6 +1,7 @@ package com.willfp.libreforge import org.bukkit.Location +import org.bukkit.block.Block import org.bukkit.entity.Entity import java.util.UUID @@ -66,6 +67,41 @@ value class EntityDispatcher( */ fun Entity.toDispatcher(): Dispatcher = EntityDispatcher(this) +@JvmInline +value class BlockDispatcher( + override val dispatcher: Block +) : Dispatcher { + override val uuid + get() = UUID(0, 0) + + override val location + get() = dispatcher.location +} + +/** + * Convert a block to a dispatcher. + */ +fun Block.toDispatcher(): Dispatcher = BlockDispatcher(this) + +/** + * A dispatcher for a location. + */ +@JvmInline +value class LocationDispatcher( + override val dispatcher: Location +) : Dispatcher { + override val uuid + get() = UUID(0, 0) + + override val location + get() = dispatcher +} + +/** + * Convert a location to a dispatcher. + */ +fun Location.toDispatcher(): Dispatcher = LocationDispatcher(this) + /** * A dispatcher for the global scope. */