Add kit system, KitManager and Goblin kit
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.
This commit is contained in:
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player
|
||||
|
||||
private val langManager get() = SpeedHG.instance.languageManager
|
||||
|
||||
private val legacySerializer = LegacyComponentSerializer.builder()
|
||||
val legacySerializer = LegacyComponentSerializer.builder()
|
||||
.character('§')
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
|
||||
116
src/main/kotlin/club/mcscrims/speedhg/util/ItemBuilder.kt
Normal file
116
src/main/kotlin/club/mcscrims/speedhg/util/ItemBuilder.kt
Normal file
@@ -0,0 +1,116 @@
|
||||
package club.mcscrims.speedhg.util
|
||||
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.inventory.ItemFlag
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class ItemBuilder(
|
||||
private val itemStack: ItemStack
|
||||
) {
|
||||
|
||||
constructor(
|
||||
type: Material
|
||||
) : this(
|
||||
ItemStack( type )
|
||||
)
|
||||
|
||||
constructor(
|
||||
type: Material,
|
||||
amount: Int
|
||||
) : this(
|
||||
ItemStack( type, amount )
|
||||
)
|
||||
|
||||
constructor() : this(
|
||||
ItemStack( Material.STONE )
|
||||
)
|
||||
|
||||
fun name(
|
||||
name: String
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta { it.displayName(Component.text( name )) }
|
||||
return this
|
||||
}
|
||||
|
||||
fun name(
|
||||
name: Component
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta { it.displayName( name ) }
|
||||
return this
|
||||
}
|
||||
|
||||
fun lore(
|
||||
lore: List<String>
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta {
|
||||
val cLore = lore.stream()
|
||||
.map( this::color )
|
||||
.map( Component::text )
|
||||
.toList()
|
||||
|
||||
it.lore( cLore as List<Component> )
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun unbreakable(
|
||||
unbreakable: Boolean
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta { it.isUnbreakable = unbreakable }
|
||||
return this
|
||||
}
|
||||
|
||||
fun amount(
|
||||
amount: Int
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.amount = amount
|
||||
return this
|
||||
}
|
||||
|
||||
fun enchant(
|
||||
ench: Enchantment
|
||||
): ItemBuilder
|
||||
{
|
||||
enchant( ench, 1 )
|
||||
return this
|
||||
}
|
||||
|
||||
fun enchant(
|
||||
ench: Enchantment,
|
||||
level: Int
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta { it.addEnchant( ench, level, true ) }
|
||||
itemFlag( ItemFlag.HIDE_ENCHANTS )
|
||||
return this
|
||||
}
|
||||
|
||||
fun itemFlag(
|
||||
flag: ItemFlag
|
||||
): ItemBuilder
|
||||
{
|
||||
itemStack.editMeta { it.addItemFlags( flag ) }
|
||||
return this
|
||||
}
|
||||
|
||||
fun build(): ItemStack
|
||||
{
|
||||
return itemStack
|
||||
}
|
||||
|
||||
private fun color(
|
||||
string: String
|
||||
): String
|
||||
{
|
||||
return ChatColor.translateAlternateColorCodes( '&', string )
|
||||
}
|
||||
|
||||
}
|
||||
37
src/main/kotlin/club/mcscrims/speedhg/util/WorldEditUtils.kt
Normal file
37
src/main/kotlin/club/mcscrims/speedhg/util/WorldEditUtils.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package club.mcscrims.speedhg.util
|
||||
|
||||
import com.sk89q.worldedit.WorldEdit
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter
|
||||
import com.sk89q.worldedit.util.SideEffectSet
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.World
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object WorldEditUtils {
|
||||
|
||||
fun createSphere(
|
||||
world: World,
|
||||
startLocation: Location,
|
||||
radius: Double,
|
||||
filled: Boolean,
|
||||
block: Material
|
||||
) = try {
|
||||
val editSession = WorldEdit.getInstance().newEditSessionBuilder()
|
||||
.world(BukkitAdapter.adapt( world )).maxBlocks( -1 ).build()
|
||||
|
||||
editSession.sideEffectApplier = SideEffectSet.defaults()
|
||||
|
||||
editSession.makeSphere(
|
||||
BukkitAdapter.asBlockVector( startLocation ),
|
||||
BukkitAdapter.asBlockState(ItemStack( block )),
|
||||
radius, filled
|
||||
)
|
||||
|
||||
editSession.commit()
|
||||
editSession.close()
|
||||
} catch ( e: Exception ) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user