Large refactor removing many legacy subsystems (abilities, kit system, database repos, recraft, world manager, extensive config classes, lunar/luckperms integrations and various listeners/commands). Introduces a lightweight LanguageManager, AntiRunningManager, ScoreboardManager, ConnectListener and a SoupListener; simplifies the main SpeedHG plugin to initialize these components and register the connection listener. Build changes: update Gradle wrapper to 8.10, remove paperweight and several external dependencies, add fr.mrmicky:fastboard and simplify shadowJar/build task configuration. Adds default language resource (languages/en_US.yml) and updates plugin/config resources. Purpose: simplify and decouple the plugin, reduce dependency surface and prepare for a leaner, modular rewrite.
55 lines
1.3 KiB
Kotlin
55 lines
1.3 KiB
Kotlin
package club.mcscrims.speedhg.util
|
|
|
|
import club.mcscrims.speedhg.SpeedHG
|
|
import net.kyori.adventure.text.Component
|
|
import net.kyori.adventure.text.minimessage.MiniMessage
|
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
|
|
import org.bukkit.entity.Player
|
|
|
|
private val langManager get() = SpeedHG.instance.languageManager
|
|
|
|
private val legacySerializer = LegacyComponentSerializer.builder()
|
|
.character('§')
|
|
.hexColors()
|
|
.useUnusualXRepeatedCharacterHexFormat()
|
|
.build()
|
|
|
|
fun Player.sendMsg(
|
|
key: String,
|
|
vararg placeholders: Pair<String, String>
|
|
) {
|
|
val component = langManager.getComponent( this, key, placeholders.toMap() )
|
|
this.sendMessage( component )
|
|
}
|
|
|
|
fun Player.trans(
|
|
key: String,
|
|
vararg placeholders: Pair<String, String>
|
|
): Component
|
|
{
|
|
return langManager.getComponent( this, key, placeholders.toMap() )
|
|
}
|
|
|
|
fun Player.transList(
|
|
key: String,
|
|
placeholders: Map<String, String>
|
|
): List<Component>
|
|
{
|
|
val rawList = langManager.getRawMessageList( this, key )
|
|
|
|
return rawList.map { line ->
|
|
var replaced = line
|
|
placeholders.forEach { (k, v) ->
|
|
replaced = replaced.replace( "<$k>", v )
|
|
}
|
|
MiniMessage.miniMessage().deserialize( replaced )
|
|
}
|
|
}
|
|
|
|
fun Component.toLegacyString(): String
|
|
{
|
|
return legacySerializer.serialize( this )
|
|
}
|
|
|
|
val Player.getDisplayName: String
|
|
get() = legacySerializer.serialize( this.displayName() ) |