mirror of
https://github.com/Auxilor/EcoJobs.git
synced 2025-12-19 15:09:24 +00:00
Merge pull request #34 from Exanthiax/level-up-effects
added level-up-effects
This commit is contained in:
@@ -134,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"
|
||||
@@ -202,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")
|
||||
)
|
||||
|
||||
val joinEffects = Effects.compileChain(
|
||||
config.getSubsections("join-effects"),
|
||||
NormalExecutorFactory.create(),
|
||||
@@ -395,6 +409,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")) {
|
||||
|
||||
@@ -155,10 +155,13 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each &a%blocks%&8 blocks mined"
|
||||
|
||||
# Commands to be sent on levelup, can be formatted two ways:
|
||||
# level:command (e.g. 10:eco give %player% 1000), which would execute that command for level 10
|
||||
# command (e.g. eco give %player% 5000), which would execute that command for all levels
|
||||
level-commands: [ ]
|
||||
# Effects to run when the skill levels up
|
||||
# %level% is the level the skill leveled up to.
|
||||
# If you want to restrict this to certain levels, you can use
|
||||
# require: %level% = 20, or require: %level% < 50, etc.
|
||||
# If you want a reward to run every x levels, you can use
|
||||
# every: 1, or every: 12, etc
|
||||
level-up-effects: [ ]
|
||||
|
||||
# The effects for the job, has %level% as a placeholder
|
||||
effects:
|
||||
|
||||
@@ -99,7 +99,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each bee you breed"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -98,7 +98,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each &a%blocks%&8 blocks placed"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -96,7 +96,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each enchanted item"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -111,7 +111,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each crop farmed"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -96,7 +96,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each fish caught"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -108,7 +108,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &7Earn &a$%money%&7 for each log chopped."
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -108,7 +108,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each &a%blocks%&8 blocks mined"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -99,7 +99,7 @@ level-up-messages:
|
||||
- "&8» &8Earn &a$%money%&8 per heart of health that"
|
||||
- " &8mobs you kill have"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -96,7 +96,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each smelted item"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
@@ -137,7 +137,7 @@ level-up-messages:
|
||||
1:
|
||||
- "&8» &8Earn &a$%money%&8 for each tool crafted"
|
||||
|
||||
level-commands: [ ]
|
||||
level-up-effects: [ ]
|
||||
|
||||
effects:
|
||||
- id: give_money
|
||||
|
||||
Reference in New Issue
Block a user