9
0
mirror of https://github.com/Auxilor/EcoJobs.git synced 2025-12-22 08:29:24 +00:00

added join-effects and leave-effects

This commit is contained in:
Exanthiax
2025-02-04 18:02:48 +00:00
parent 6fc1ba72d8
commit e6c486bc3a
2 changed files with 16 additions and 0 deletions

View File

@@ -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<Int> = PersistentDataKey(
EcoJobsPlugin.instance.namespacedKeyFactory.create("${id}_level"),
PersistentDataKeyType.INT,

View File

@@ -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())
}
}