Introduce a full kit framework and supporting utilities. - Add core kit API: Kit, Playstyle, ActiveAbility, PassiveAbility, AbilityResult, charge state and PlayerChargeData. - Implement KitManager for registration, lobby selections, apply/remove/clear lifecycle and charge tracking. - Add KitEventDispatcher listener to centralize kit event handling (interact, hits, move) and integrate passive/active hooks. - Provide example kit implementations: GoblinKit (functional abilities) and TemplateKit (reference). - Add utilities: ItemBuilder and WorldEditUtils (WorldEdit-based sphere creation). - Integrate into plugin: SpeedHG now initialises KitManager, registers kits and KitEventDispatcher, applies kits at game start and clears on end. - LanguageManager: add default message/list/component helpers. - Build changes: bump Kotlin plugin to 2.2.0 and add WorldEdit compileOnly deps; also expose legacySerializer in Extensions. These changes implement the kit feature set (items, abilities, charge/recharge flow) and wire it into the game lifecycle.
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
|
|
|
|
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() ) |