diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedQuest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedQuest.kt index f8c768a..05e5da4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedQuest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedQuest.kt @@ -2,9 +2,12 @@ package com.willfp.ecoquests.libreforge import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecoquests.quests.Quests +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 org.bukkit.entity.Player object ConditionHasCompletedQuest : Condition("has_completed_quest") { @@ -12,7 +15,14 @@ object ConditionHasCompletedQuest : Condition("has_completed_ques require("quest", "You must specify the quest ID!") } - 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 quest = Quests[config.getString("quest")] ?: return false return quest.hasCompleted(player) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedTask.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedTask.kt index 94c1d54..2037c5f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedTask.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasCompletedTask.kt @@ -3,9 +3,12 @@ package com.willfp.ecoquests.libreforge import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecoquests.quests.Quests import com.willfp.ecoquests.tasks.Tasks +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 org.bukkit.entity.Player object ConditionHasCompletedTask : Condition("has_completed_task") { @@ -14,7 +17,14 @@ object ConditionHasCompletedTask : Condition("has_completed_task" require("task", "You must specify the task ID!") } - 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 quest = Quests[config.getString("quest")] ?: return false val template = Tasks[config.getString("task")] ?: return false val task = quest.getTask(template) ?: return false diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasQuestActive.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasQuestActive.kt index 63cc769..b988dac 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasQuestActive.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/ConditionHasQuestActive.kt @@ -2,9 +2,12 @@ package com.willfp.ecoquests.libreforge import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecoquests.quests.Quests +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 org.bukkit.entity.Player object ConditionHasQuestActive : Condition("has_quest_active") { @@ -12,7 +15,14 @@ object ConditionHasQuestActive : Condition("has_quest_active") { require("quest", "You must specify the quest ID!") } - 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 quest = Quests[config.getString("quest")] ?: return false return quest.hasActive(player) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/EffectQuestXpMultiplier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/EffectQuestXpMultiplier.kt index 4d932b3..e589e51 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/EffectQuestXpMultiplier.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/EffectQuestXpMultiplier.kt @@ -4,6 +4,7 @@ import com.willfp.ecoquests.api.event.PlayerTaskExpGainEvent import com.willfp.ecoquests.quests.Quest import com.willfp.ecoquests.quests.Quests import com.willfp.libreforge.effects.templates.MultiMultiplierEffect +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectQuestXpMultiplier : MultiMultiplierEffect("quest_xp_multiplier") { @@ -19,6 +20,6 @@ object EffectQuestXpMultiplier : MultiMultiplierEffect("quest_xp_multipli @EventHandler(ignoreCancelled = true) fun handle(event: PlayerTaskExpGainEvent) { - event.amount *= getMultiplier(event.player, event.quest) + event.amount *= getMultiplier(event.player.toDispatcher(), event.quest) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteQuest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteQuest.kt index 8c03013..ae8937f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteQuest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteQuest.kt @@ -2,6 +2,7 @@ package com.willfp.ecoquests.libreforge import com.willfp.ecoquests.api.event.PlayerQuestCompleteEvent import com.willfp.ecoquests.api.event.PlayerQuestStartEvent +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 +19,7 @@ object TriggerCompleteQuest : Trigger("complete_quest") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteTask.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteTask.kt index 6d877e1..1b895f3 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteTask.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerCompleteTask.kt @@ -1,6 +1,7 @@ package com.willfp.ecoquests.libreforge import com.willfp.ecoquests.api.event.PlayerTaskCompleteEvent +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 +18,7 @@ object TriggerCompleteTask : Trigger("complete_task") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerGainTaskXp.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerGainTaskXp.kt index 18bf386..38e2af3 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerGainTaskXp.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerGainTaskXp.kt @@ -1,6 +1,7 @@ package com.willfp.ecoquests.libreforge import com.willfp.ecoquests.api.event.PlayerTaskExpGainEvent +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 +20,7 @@ object TriggerGainTaskXp : Trigger("gain_task_xp") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, event = event, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerStartQuest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerStartQuest.kt index 98c4bf3..ac70f96 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerStartQuest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/libreforge/TriggerStartQuest.kt @@ -1,6 +1,7 @@ package com.willfp.ecoquests.libreforge import com.willfp.ecoquests.api.event.PlayerQuestStartEvent +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 +18,7 @@ object TriggerStartQuest : Trigger("start_quest") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, event = event diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt index faf7f20..4b2b4dd 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/quests/Quest.kt @@ -28,6 +28,7 @@ import com.willfp.libreforge.ViolationContext import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.effects.Effects import com.willfp.libreforge.effects.executors.impl.NormalExecutorFactory +import com.willfp.libreforge.toDispatcher import org.bukkit.Bukkit import org.bukkit.OfflinePlayer import org.bukkit.entity.Player @@ -58,7 +59,7 @@ class Quest( ) addLoreLines( - startConditions.getNotMetLines(player, EmptyProvidedHolder) + startConditions.getNotMetLines(player.toDispatcher(), EmptyProvidedHolder) ) setDisplayName( @@ -257,7 +258,7 @@ class Quest( } fun meetsStartConditions(player: Player): Boolean { - return startConditions.areMet(player, EmptyProvidedHolder) + return startConditions.areMet(player.toDispatcher(), EmptyProvidedHolder) } fun shouldStart(player: Player): Boolean { @@ -282,7 +283,7 @@ class Quest( return } - startEffects?.trigger(player) + startEffects?.trigger(player.toDispatcher()) player.profile.write(hasStartedKey, true) player.profile.write(startedTimeKey, currentTimeMinutes) @@ -408,7 +409,7 @@ class Quest( private fun complete(player: Player) { player.profile.write(hasCompletedKey, true) player.profile.write(completedTimeKey, currentTimeMinutes) - rewards?.trigger(player) + rewards?.trigger(player.toDispatcher()) Bukkit.getPluginManager().callEvent(PlayerQuestCompleteEvent(player, this)) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt index 6a8af9d..95f2db3 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoquests/tasks/Task.kt @@ -15,6 +15,7 @@ import com.willfp.ecoquests.api.event.PlayerTaskExpGainEvent import com.willfp.ecoquests.quests.Quest import com.willfp.ecoquests.quests.Quests import com.willfp.libreforge.counters.Accumulator +import com.willfp.libreforge.toDispatcher import org.bukkit.Bukkit import org.bukkit.OfflinePlayer import org.bukkit.entity.Player @@ -152,7 +153,7 @@ class Task( if (newXp >= requiredXp) { player.profile.write(hasCompletedKey, true) - template.onComplete?.trigger(player) + template.onComplete?.trigger(player.toDispatcher()) Bukkit.getPluginManager().callEvent(PlayerTaskCompleteEvent(player, template, quest)) diff --git a/gradle.properties b/gradle.properties index 7cebcf0..e975e7e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater -#Sun Nov 19 14:14:25 GMT 2023 +#Tue Nov 21 22:41:42 GMT 2023 kotlin.code.style=official -libreforge-version=4.43.1 -version=1.15.1 +libreforge-version=4.44.0 +version=1.16.0