From e6c486bc3a8d10dc9c999a2fa74be270962f7f11 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 4 Feb 2025 18:02:48 +0000 Subject: [PATCH 1/4] added join-effects and leave-effects --- .../src/main/kotlin/com/willfp/ecojobs/jobs/Job.kt | 13 +++++++++++++ .../kotlin/com/willfp/ecojobs/jobs/PriceHandler.kt | 3 +++ 2 files changed, 16 insertions(+) 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 752f8b9..9ded74a 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 @@ -33,6 +33,7 @@ import com.willfp.libreforge.conditions.Conditions import com.willfp.libreforge.counters.Counters import com.willfp.libreforge.effects.EffectList import com.willfp.libreforge.effects.Effects +import com.willfp.libreforge.effects.executors.impl.NormalExecutorFactory import org.bukkit.Bukkit import org.bukkit.OfflinePlayer import org.bukkit.configuration.InvalidConfigurationException @@ -66,6 +67,18 @@ class Job( PriceEconomy(config.getDouble("leave-price")), "" ) + 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") + ) + val levelKey: PersistentDataKey = PersistentDataKey( EcoJobsPlugin.instance.namespacedKeyFactory.create("${id}_level"), PersistentDataKeyType.INT, 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()) } } From 7065642d976989be055edb7985c66eca3967c196 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 4 Feb 2025 18:04:56 +0000 Subject: [PATCH 2/4] Update _example.yml --- .../src/main/resources/jobs/_example.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 b37ec7e..73200dc 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 From 533d036a1813f09c43c84c7a935bac0874dda318 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Tue, 4 Feb 2025 23:12:04 +0000 Subject: [PATCH 3/4] moved below placeholders --- .../kotlin/com/willfp/ecojobs/jobs/Job.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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 9ded74a..ee3c981 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 @@ -67,18 +67,6 @@ class Job( PriceEconomy(config.getDouble("leave-price")), "" ) - 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") - ) - val levelKey: PersistentDataKey = PersistentDataKey( EcoJobsPlugin.instance.namespacedKeyFactory.create("${id}_level"), PersistentDataKeyType.INT, @@ -214,6 +202,18 @@ class Job( }.register() } + 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)) } } From cdcc45aef8e640e69d91d880db6aeb5b12660f35 Mon Sep 17 00:00:00 2001 From: Exanthiax <107284021+Exanthiax@users.noreply.github.com> Date: Sun, 9 Mar 2025 22:52:32 +0000 Subject: [PATCH 4/4] update all current jobs --- eco-core/core-plugin/src/main/resources/jobs/beekeeper.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/builder.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/enchanter.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/farmer.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/fisherman.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/lumberjack.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/miner.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/slayer.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/smelter.yml | 4 ++++ eco-core/core-plugin/src/main/resources/jobs/toolsmith.yml | 4 ++++ 10 files changed, 40 insertions(+) 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 cc96120..9ad6287 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 ec52196..64cd1ba 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 eb7881b..4f30762 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 9b9163c..be74559 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 6a0046a..ebe15fc 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 765f7dd..8bae52a 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 9ee7a53..3169dba 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 4fff9f7..a451c74 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 8fa00cd..b384f97 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 10ba906..9328452 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: - ""