9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2025-12-31 12:56:31 +00:00

Fixed boss bar bugs

This commit is contained in:
Auxilor
2022-01-03 19:39:07 +00:00
parent 519ca8c3ac
commit 44cfb93019
2 changed files with 11 additions and 3 deletions

View File

@@ -63,16 +63,22 @@ class SkillDisplayListener(
string = string.replace("%gained_xp%", NumberUtils.format(amount))
val ratio = currentXp / nextLevel
val bossBar = Bukkit.createBossBar(
val key = plugin.namespacedKeyFactory.create("${player.name.substring(0, 2)}${skill.id}")
val bossBar = Bukkit.getBossBar(key) ?: Bukkit.createBossBar(
key,
string,
BarColor.valueOf(this.plugin.configYml.getString("skills.progress.boss-bar.color").uppercase()),
BarStyle.valueOf(this.plugin.configYml.getString("skills.progress.boss-bar.style").uppercase())
)
bossBar.setTitle(string)
bossBar.progress = ratio
bossBar.addPlayer(player)
this.plugin.scheduler.runLater(this.plugin.configYml.getInt("skills.progress.boss-bar.duration").toLong()) {
this.plugin.scheduler.runLater(
this.plugin.configYml.getInt("skills.progress.boss-bar.duration").toLong()
) {
bossBar.removePlayer(player)
}
}

View File

@@ -243,11 +243,13 @@ skills:
# If the boss bar should be used
enabled: false
# The boss bar message that should be sent
format: "&f%skill% &8| &9(%current_xp%/%required_xp%) &e+%gained_xp%"
format: "&f%skill% &8| &9(%current_xp%/%required_xp%)"
# The color of the boss bar (from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BarColor.html)
color: pink
# The style of the boss bar (from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BarStyle.html)
style: solid
# How long the boss bar should last (in ticks)
duration: 60
sound:
# If a sound should be played
enabled: true