diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/EcoJobsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/EcoJobsPlugin.kt index b8dff0e..003c514 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/EcoJobsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/EcoJobsPlugin.kt @@ -30,7 +30,9 @@ import com.willfp.libreforge.filters.Filters import com.willfp.libreforge.loader.LibreforgePlugin import com.willfp.libreforge.loader.configs.ConfigCategory import com.willfp.libreforge.registerHolderProvider +import com.willfp.libreforge.registerSpecificHolderProvider import com.willfp.libreforge.triggers.Triggers +import org.bukkit.entity.Player import org.bukkit.event.Listener import java.util.regex.Pattern @@ -56,7 +58,7 @@ class EcoJobsPlugin : LibreforgePlugin() { Triggers.register(TriggerLeaveJob) Filters.register(FilterJob) - registerHolderProvider { player -> + registerSpecificHolderProvider { player -> player.activeJobs.map { it.getLevel(player.getJobLevel(it)) }.map { SimpleProvidedHolder(it) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasActiveJob.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasActiveJob.kt index 95499e6..9ddd6f4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasActiveJob.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasActiveJob.kt @@ -2,9 +2,12 @@ package com.willfp.ecojobs.libreforge import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecojobs.api.activeJobs +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 ConditionHasActiveJob : Condition("has_active_job") { @@ -12,7 +15,14 @@ object ConditionHasActiveJob : Condition("has_active_job") { require("job", "You must specify the job!") } - 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.activeJobs.any { it.id == config.getString("job").lowercase() } } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasJobLevel.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasJobLevel.kt index 939c261..7871378 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasJobLevel.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/ConditionHasJobLevel.kt @@ -4,9 +4,13 @@ import com.willfp.eco.core.config.interfaces.Config import com.willfp.ecojobs.api.event.PlayerJobLevelUpEvent import com.willfp.ecojobs.api.getJobLevel import com.willfp.ecojobs.jobs.Jobs +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.toDispatcher import com.willfp.libreforge.updateEffects import org.bukkit.entity.Player import org.bukkit.event.EventHandler @@ -18,7 +22,14 @@ object ConditionHasJobLevel : Condition("has_job_level") { require("level", "You must specify the 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.getJobLevel( Jobs.getByID(config.getString("job").lowercase()) ?: return false ) >= config.getIntFromExpression("level", player) @@ -26,6 +37,6 @@ object ConditionHasJobLevel : Condition("has_job_level") { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun handle(event: PlayerJobLevelUpEvent) { - event.player.updateEffects() + event.player.toDispatcher().updateEffects() } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/EffectJobXpMultiplier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/EffectJobXpMultiplier.kt index a7ec02a..0ea1aca 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/EffectJobXpMultiplier.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/EffectJobXpMultiplier.kt @@ -4,6 +4,7 @@ import com.willfp.ecojobs.api.event.PlayerJobExpGainEvent import com.willfp.ecojobs.jobs.Job import com.willfp.ecojobs.jobs.Jobs import com.willfp.libreforge.effects.templates.MultiMultiplierEffect +import com.willfp.libreforge.toDispatcher import org.bukkit.event.EventHandler object EffectJobXpMultiplier : MultiMultiplierEffect("job_xp_multiplier") { @@ -19,6 +20,6 @@ object EffectJobXpMultiplier : MultiMultiplierEffect("job_xp_multiplier") { @EventHandler(ignoreCancelled = true) fun handle(event: PlayerJobExpGainEvent) { - event.amount *= getMultiplier(event.player, event.job) + event.amount *= getMultiplier(event.player.toDispatcher(), event.job) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerGainJobXp.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerGainJobXp.kt index fe4cd16..97fc745 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerGainJobXp.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerGainJobXp.kt @@ -1,6 +1,7 @@ package com.willfp.ecojobs.libreforge import com.willfp.ecojobs.api.event.PlayerJobExpGainEvent +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 TriggerGainJobXp : Trigger("gain_job_xp") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerJoinJob.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerJoinJob.kt index 097e7fc..81bc9c8 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerJoinJob.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerJoinJob.kt @@ -2,6 +2,7 @@ package com.willfp.ecojobs.libreforge import com.willfp.ecojobs.api.event.PlayerJobJoinEvent import com.willfp.ecojobs.api.getJobLevel +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 +21,7 @@ object TriggerJoinJob : Trigger("join_job") { val player = event.player as? Player ?: return this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLeaveJob.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLeaveJob.kt index 32ec598..6de90b5 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLeaveJob.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLeaveJob.kt @@ -2,6 +2,7 @@ package com.willfp.ecojobs.libreforge import com.willfp.ecojobs.api.event.PlayerJobLeaveEvent import com.willfp.ecojobs.api.getJobLevel +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 TriggerLeaveJob : Trigger("leave_job") { val player = event.player as? Player ?: return this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLevelUpJob.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLevelUpJob.kt index 4627afe..b54418f 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLevelUpJob.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/libreforge/TriggerLevelUpJob.kt @@ -1,6 +1,7 @@ package com.willfp.ecojobs.libreforge import com.willfp.ecojobs.api.event.PlayerJobLevelUpEvent +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 TriggerLevelUpJob : Trigger("level_up_job") { val player = event.player this.dispatch( - player, + player.toDispatcher(), TriggerData( player = player, location = player.location, diff --git a/gradle.properties b/gradle.properties index a9bae70..da43e05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ #libreforge-updater -#Sun Nov 19 14:13:20 GMT 2023 +#Tue Nov 21 22:40:38 GMT 2023 kotlin.code.style=official -libreforge-version=4.43.1 -version=3.42.1 +libreforge-version=4.44.0 +version=3.43.0