diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt index aebf888..253dc30 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt @@ -215,6 +215,18 @@ class Job( NormalExecutorFactory.create(), ViolationContext(plugin, "Job $id level-up-effects") ) + + val joinEffects = Effects.compileChain( + config.getSubsections("join-effects"), + NormalExecutorFactory.create(), + ViolationContext(plugin, "Job $id join-effects") + ) + + val leaveEffects = Effects.compileChain( + config.getSubsections("leave-effects"), + NormalExecutorFactory.create(), + ViolationContext(plugin, "Job $id leave-effects") + ) override fun onRegister() { jobXpGains.forEach { it.bind(JobXPAccumulator(this)) } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/PriceHandler.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/PriceHandler.kt index 7c64df2..091fe27 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/PriceHandler.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecojobs/jobs/PriceHandler.kt @@ -2,6 +2,7 @@ package com.willfp.ecojobs.jobs import com.willfp.ecojobs.api.event.PlayerJobJoinEvent import com.willfp.ecojobs.api.event.PlayerJobLeaveEvent +import com.willfp.libreforge.toDispatcher import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -23,6 +24,7 @@ object PriceHandler : Listener { } price.pay(player) + job.joinEffects?.trigger(player.toDispatcher()) } @EventHandler( @@ -40,5 +42,6 @@ object PriceHandler : Listener { } price.pay(player) + job.leaveEffects?.trigger(player.toDispatcher()) } } diff --git a/eco-core/core-plugin/src/main/resources/jobs/_example.yml b/eco-core/core-plugin/src/main/resources/jobs/_example.yml index 6b39980..ba27ce7 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/_example.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/_example.yml @@ -27,6 +27,13 @@ join-price: # Reference with %join_lore% join-lore: [] +# A list of effects to run when the player joins the job. +# Read https://plugins.auxilor.io/effects/configuring-an-effect +join-effects: + - id: broadcast + args: + message: "&8» &a%player% &8joined the &6Miner &8job!" + # The price to leave this job (set to 0 to disable) # Read here for more: https://plugins.auxilor.io/all-plugins/prices leave-price: @@ -39,6 +46,13 @@ leave-price: leave-lore: - " &8» This will cost %leave_price%" +# A list of effects to run when the player leaves the job. +# Read https://plugins.auxilor.io/effects/configuring-an-effect +leave-effects: + - id: send_message + args: + message: "&8» &8You left the &6Miner &8job!" + # There are two ways to specify level XP requirements: # 1. A formula to calculate for infinite levels # 2. A list of XP requirements for each level diff --git a/eco-core/core-plugin/src/main/resources/jobs/beekeeper.yml b/eco-core/core-plugin/src/main/resources/jobs/beekeeper.yml index 8881921..262265f 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/beekeeper.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/beekeeper.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/builder.yml b/eco-core/core-plugin/src/main/resources/jobs/builder.yml index 7ef0945..0b33817 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/builder.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/builder.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/enchanter.yml b/eco-core/core-plugin/src/main/resources/jobs/enchanter.yml index 9bef815..b1a1d8a 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/enchanter.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/enchanter.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/farmer.yml b/eco-core/core-plugin/src/main/resources/jobs/farmer.yml index ebd3092..11cabae 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/farmer.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/farmer.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/fisherman.yml b/eco-core/core-plugin/src/main/resources/jobs/fisherman.yml index 73bf173..cf33948 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/fisherman.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/fisherman.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/lumberjack.yml b/eco-core/core-plugin/src/main/resources/jobs/lumberjack.yml index 411f139..29f03b1 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/lumberjack.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/lumberjack.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/miner.yml b/eco-core/core-plugin/src/main/resources/jobs/miner.yml index 29e3291..9d0d994 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/miner.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/miner.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/slayer.yml b/eco-core/core-plugin/src/main/resources/jobs/slayer.yml index 972d9b1..4ec4e74 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/slayer.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/slayer.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/smelter.yml b/eco-core/core-plugin/src/main/resources/jobs/smelter.yml index ce3cc90..8f583ad 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/smelter.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/smelter.yml @@ -10,6 +10,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -17,6 +19,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - "" diff --git a/eco-core/core-plugin/src/main/resources/jobs/toolsmith.yml b/eco-core/core-plugin/src/main/resources/jobs/toolsmith.yml index 2a48506..480c5d4 100644 --- a/eco-core/core-plugin/src/main/resources/jobs/toolsmith.yml +++ b/eco-core/core-plugin/src/main/resources/jobs/toolsmith.yml @@ -18,6 +18,8 @@ join-price: type: coins display: "&a$%value%" +join-effects: [] + join-lore: [] leave-price: @@ -25,6 +27,8 @@ leave-price: type: coins display: "&a$%value%" +leave-effects: [] + leave-lore: - ""