mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-04 15:41:36 +00:00
Added title messages to skill level up
This commit is contained in:
@@ -2,9 +2,12 @@ package com.willfp.ecoskills.skills.display
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.sound.PlayableSound
|
||||
import com.willfp.eco.util.toComponent
|
||||
import com.willfp.ecoskills.api.event.PlayerSkillLevelUpEvent
|
||||
import net.kyori.adventure.title.Title
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import java.time.Duration
|
||||
|
||||
class LevelUpDisplay(
|
||||
private val plugin: EcoPlugin
|
||||
@@ -33,6 +36,27 @@ class LevelUpDisplay(
|
||||
formatted.forEach { player.sendMessage(it) }
|
||||
}
|
||||
|
||||
if (plugin.configYml.getBool("skills.level-up.title.enabled")) {
|
||||
val rawTitle = plugin.configYml.getString("skills.level-up.title.title")
|
||||
val rawSubtitle = plugin.configYml.getString("skills.level-up.title.subtitle")
|
||||
|
||||
val formatted = skill.addPlaceholdersInto(
|
||||
listOf(rawTitle, rawSubtitle),
|
||||
player,
|
||||
level = level
|
||||
)
|
||||
|
||||
player.showTitle(Title.title(
|
||||
formatted[0].toComponent(),
|
||||
formatted[1].toComponent(),
|
||||
Title.Times.times(
|
||||
Duration.ofSeconds((plugin.configYml.getInt("skills.level-up.title.fade-in")/20).toLong()),
|
||||
Duration.ofSeconds((plugin.configYml.getInt("skills.level-up.title.stay")/20).toLong()),
|
||||
Duration.ofSeconds((plugin.configYml.getInt("skills.level-up.title.fade-out")/20).toLong())
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
sound?.playTo(player)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,6 +316,13 @@ skills:
|
||||
- " &#ff00ae&lREWARDS:"
|
||||
- "%rewards%"
|
||||
- "&f"
|
||||
title:
|
||||
enabled: true
|
||||
fade-in: 10
|
||||
stay: 40
|
||||
fade-out: 10
|
||||
title: "&a%skill% &levelled up!"
|
||||
subtitle: "&66%level_previous_numeral% &8» &6%level_numeral%"
|
||||
sound:
|
||||
# If a sound should be played
|
||||
enabled: true
|
||||
|
||||
Reference in New Issue
Block a user