mirror of
https://github.com/Auxilor/EcoJobs.git
synced 2025-12-28 03:19:11 +00:00
added level-up-effects
added `level-up-effects` deprecated `level-commands` with message
This commit is contained in:
@@ -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
|
||||
@@ -133,24 +134,7 @@ class Job(
|
||||
ViolationContext(plugin, "Job $id")
|
||||
)
|
||||
|
||||
for (string in config.getStrings("level-commands")) {
|
||||
val split = string.split(":")
|
||||
|
||||
if (split.size == 1) {
|
||||
for (level in 1..maxLevel) {
|
||||
val commands = levelCommands[level] ?: mutableListOf()
|
||||
commands.add(string)
|
||||
levelCommands[level] = commands
|
||||
}
|
||||
} else {
|
||||
val level = split[0].toInt()
|
||||
|
||||
val command = string.removePrefix("$level:")
|
||||
val commands = levelCommands[level] ?: mutableListOf()
|
||||
commands.add(command)
|
||||
levelCommands[level] = commands
|
||||
}
|
||||
}
|
||||
manageLevelCommands(config)
|
||||
|
||||
PlayerPlaceholder(
|
||||
plugin, "${id}_percentage_progress"
|
||||
@@ -201,6 +185,37 @@ class Job(
|
||||
}.register()
|
||||
}
|
||||
|
||||
@Deprecated("Use level-up-effects instead")
|
||||
private fun manageLevelCommands(config: Config) {
|
||||
if (config.getStrings("level-commands").isNotEmpty()) {
|
||||
plugin.logger.warning("$id job: The `level-commands` key is deprecated and will be removed in future versions. Switch to `level-up-effects` instead. Refer to the wiki for more info.")
|
||||
}
|
||||
for (string in config.getStrings("level-commands")) {
|
||||
val split = string.split(":")
|
||||
|
||||
if (split.size == 1) {
|
||||
for (level in 1..maxLevel) {
|
||||
val commands = levelCommands[level] ?: mutableListOf()
|
||||
commands.add(string)
|
||||
levelCommands[level] = commands
|
||||
}
|
||||
} else {
|
||||
val level = split[0].toInt()
|
||||
|
||||
val command = string.removePrefix("$level:")
|
||||
val commands = levelCommands[level] ?: mutableListOf()
|
||||
commands.add(command)
|
||||
levelCommands[level] = commands
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val levelUpEffects = Effects.compileChain(
|
||||
config.getSubsections("level-up-effects"),
|
||||
NormalExecutorFactory.create(),
|
||||
ViolationContext(plugin, "Job $id level-up-effects")
|
||||
)
|
||||
|
||||
override fun onRegister() {
|
||||
jobXpGains.forEach { it.bind(JobXPAccumulator(this)) }
|
||||
}
|
||||
@@ -382,6 +397,7 @@ class Job(
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Use level-up-effects instead")
|
||||
fun executeLevelCommands(player: Player, level: Int) {
|
||||
val commands = levelCommands[level] ?: emptyList()
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.willfp.ecojobs.jobs
|
||||
|
||||
import com.willfp.ecojobs.EcoJobsPlugin
|
||||
import com.willfp.ecojobs.api.event.PlayerJobLevelUpEvent
|
||||
import com.willfp.libreforge.toDispatcher
|
||||
import org.bukkit.Sound
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
@@ -16,6 +17,7 @@ class JobLevelListener(
|
||||
val player = event.player
|
||||
val level = event.level
|
||||
|
||||
job.levelUpEffects?.trigger(player.toDispatcher())
|
||||
job.executeLevelCommands(player, level)
|
||||
|
||||
if (this.plugin.configYml.getBool("level-up.sound.enabled")) {
|
||||
|
||||
Reference in New Issue
Block a user