9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-01 21:36:34 +00:00

Added level up commands

This commit is contained in:
Auxilor
2021-09-09 10:37:11 +01:00
parent 2b2d3271bf
commit 772a66d052
11 changed files with 41 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import com.willfp.ecoskills.config.SkillConfig
import com.willfp.ecoskills.effects.Effect
import com.willfp.ecoskills.effects.Effects
import com.willfp.ecoskills.stats.Stats
import org.bukkit.Bukkit
import org.bukkit.NamespacedKey
import org.bukkit.entity.Player
import org.bukkit.event.Listener
@@ -27,6 +28,7 @@ abstract class Skill(
lateinit var gui: SkillGUI
var maxLevel: Int = 50
private val rewards = mutableListOf<SkillObjectReward>()
private val levelCommands = mutableMapOf<Int, MutableList<String>>()
// Cached values
private val guiLoreCache = mutableMapOf<Int, List<String>>()
@@ -55,6 +57,17 @@ abstract class Skill(
}
}
levelCommands.clear()
for (string in config.getStrings("rewards.level-commands", false)) {
val split = string.split(":")
val level = split[0].toInt()
val command = split[1]
val commands = levelCommands[level] ?: mutableListOf()
commands.add(command)
levelCommands[level] = commands
}
PlaceholderEntry(
id,
{ player -> player.getSkillLevel(this).toString() },
@@ -201,6 +214,14 @@ abstract class Skill(
return lore
}
fun executeLevelCommands(player: Player, level: Int) {
val commands = levelCommands[level] ?: emptyList()
for (command in commands) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("%player%", player.name))
}
}
open fun postUpdate() {
// Override when needed
}

View File

@@ -31,5 +31,7 @@ class SkillLevellingListener : Listener {
}
}
}
skill.executeLevelCommands(player, to)
}
}

View File

@@ -29,6 +29,8 @@ rewards:
- "efficient_brewing::1:10:100"
- "mystic_resilience::1"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -29,6 +29,8 @@ rewards:
- "infernal_resistance::1"
- "bravery::1:10:100"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -32,6 +32,8 @@ rewards:
- "strong_impact::1:10:100"
- "endangering::1:20:100"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -29,6 +29,8 @@ rewards:
- "reimbursement::1"
- "overcompensation::1:10:100"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -29,6 +29,8 @@ rewards:
- "dodging::1"
- "accelerated_escape::1:10:100"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -29,6 +29,8 @@ rewards:
- "satiation::1"
- "golden_yield::1:10:100"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -23,6 +23,8 @@ rewards:
- "wisdom::1"
- "eye_of_the_depths::1"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -29,6 +29,8 @@ rewards:
- "spelunking::1:10:100"
- "dynamic_mining::1"
level-commands: []
# The chat messages to send on level up
chat-messages:
1:

View File

@@ -26,6 +26,8 @@ rewards:
- "craftsmanship::1"
- "master_lumberjack::1"
level-commands: []
# The chat messages to send on level up
chat-messages:
1: