Fix start errors

This commit is contained in:
TDSTOS
2025-12-12 05:12:09 +01:00
parent 1acb5681fc
commit bb47145a73
16 changed files with 200 additions and 61 deletions

View File

@@ -10,6 +10,7 @@ import org.bukkit.entity.Player
import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.player.PlayerMoveEvent
import org.bukkit.inventory.ItemStack
abstract class AbstractKit(
val id: String,
@@ -23,6 +24,7 @@ abstract class AbstractKit(
) {
lateinit var config: Map<String, Double>
val items = mutableListOf<ItemStack>()
abstract fun onSelect( player: Player )
@@ -93,7 +95,7 @@ abstract class AbstractKit(
}
enum class PlayStyle {
OFFENSIVE, DEFENSIVE, NULL
OFFENSIVE, DEFENSIVE
}
enum class KitMetaData {

View File

@@ -70,6 +70,7 @@ class KitManager(
Component::class.java,
List::class.java,
Material::class.java,
PlayStyle::class.java,
SpeedHG::class.java,
AbilityContext::class.java,
GameManager::class.java
@@ -80,7 +81,7 @@ class KitManager(
displayName,
description,
icon,
PlayStyle.NULL,
PlayStyle.DEFENSIVE,
plugin,
plugin.abilityContext,
plugin.gameManager

View File

@@ -46,11 +46,12 @@ class AnchorKit(
player: Player
) {
anvilItem = ItemBuilder( plugin, Material.ANVIL )
.name(plugin.chatFormatter.format( "kits.anchor.items.anvil.${playStyle.name.lowercase()}" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "anchor", "anvil" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.add( anvilItem )
player.inventory.setItem( 0, anvilItem )
}

View File

@@ -1,15 +1,20 @@
package club.mcscrims.speedhg.kit.impl
import club.mcscrims.speedhg.SpeedHG
import club.mcscrims.speedhg.SpeedHG.Companion.content
import club.mcscrims.speedhg.ability.AbilityContext
import club.mcscrims.speedhg.game.GameManager
import club.mcscrims.speedhg.kit.AbstractKit
import club.mcscrims.speedhg.kit.KitMetaData
import club.mcscrims.speedhg.kit.PlayStyle
import club.mcscrims.spigot.item.ItemBuilder
import club.mcscrims.spigot.util.GroundDetector
import net.kyori.adventure.text.Component
import org.bukkit.Bukkit
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.Particle
import org.bukkit.entity.EnderPearl
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
import org.bukkit.event.block.Action
import org.bukkit.event.entity.EntityDamageByEntityEvent
@@ -17,6 +22,12 @@ import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.player.PlayerMoveEvent
import org.bukkit.inventory.ItemStack
import org.bukkit.metadata.FixedMetadataValue
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import org.bukkit.scheduler.BukkitRunnable
import org.bukkit.util.Vector
import kotlin.math.max
import kotlin.math.roundToInt
class BlackPantherKit(
id: String,
@@ -46,33 +57,33 @@ class BlackPantherKit(
PlayStyle.DEFENSIVE ->
{
blackDye = ItemBuilder( plugin, Material.BLACK_DYE )
.name(plugin.chatFormatter.format( "kits.anchor.items.blackDye.${playStyle.name.lowercase()}" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blackpanther", "blackDye" )!![ "null" ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.add( blackDye )
player.inventory.setItem( 0, blackDye )
}
PlayStyle.OFFENSIVE ->
{
blackDye = ItemBuilder( plugin, Material.BLACK_DYE )
.name(plugin.chatFormatter.format( "kits.anchor.items.blackDye.${playStyle.name.lowercase()}" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blackpanther", "blackDye" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
blazePowder = ItemBuilder( plugin, Material.BLAZE_POWDER )
.name(plugin.chatFormatter.format( "kits.anchor.items.blazePowder" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blackpanther", "blazePowder" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.addAll(listOf( blackDye, blazePowder ))
player.inventory.setItem( 0, blackDye )
player.inventory.setItem( 1, blazePowder )
}
else -> {}
}
}
@@ -127,11 +138,11 @@ class BlackPantherKit(
if ( playStyle == PlayStyle.DEFENSIVE )
{
launchAndDash( player )
return
}
push( player )
}
Material.BLAZE_POWDER ->
@@ -153,6 +164,101 @@ class BlackPantherKit(
override fun onMove( player: Player, event: PlayerMoveEvent ) {}
private fun push(
player: Player
) {
plugin.getAlivePlayers().stream()
.filter { it != player }
.filter { it.location.distance( player.location ) <= defaultRadius }
.forEach { nearby ->
val pushDirection = nearby.location.toVector().subtract( player.location.toVector() ).normalize()
pushDirection.multiply( 1.0 )
pushDirection.setY( 0.5 )
nearby.velocity = pushDirection
val enderPearl = player.world.spawnEntity( player.location, EntityType.ENDER_PEARL ) as EnderPearl
enderPearl.velocity = pushDirection
enderPearl.setMetadata( KitMetaData.IS_BLACK_PANTHER.getKey(), FixedMetadataValue( plugin, true ))
object : BukkitRunnable()
{
override fun run()
{
if (GroundDetector.isOnGround( nearby ))
{
this.cancel()
return
}
nearby.world.spawnParticle( Particle.END_ROD, nearby.location, 5, 0.2, 0.2, 0.2 )
}
}.runTaskTimer( plugin, 0L, 2L )
}
}
private fun launchAndDash(
player: Player,
upwardVelocity: Double = 2.2,
waitTicks: Long = 60L,
dashSpeed: Double = 2.8,
horizontalOnly: Boolean = true,
yBoost: Double = 0.2,
noFallDamageMillis: Double = 1.0
) {
if ( !player.isOnline ) return
if ( player.isInsideVehicle ) player.leaveVehicle()
if ( player.gameMode == GameMode.SPECTATOR ) return
player.velocity = Vector( 0.0, upwardVelocity, 0.0 )
player.fallDistance = 0f
if ( noFallDamageMillis > 0 )
player.addPotionEffect(PotionEffect( PotionEffectType.RESISTANCE, ( noFallDamageMillis * 20 ).toInt(), 999, false, false, false ))
Bukkit.getScheduler().runTaskLater( plugin, { ->
val p = Bukkit.getPlayer( player.uniqueId ) ?: return@runTaskLater
if ( !p.isOnline ) return@runTaskLater
var dir = p.eyeLocation.direction
if ( horizontalOnly ) dir = Vector( dir.x, 0.0, dir.z )
dir = if ( dir.lengthSquared() < 1e-6 ) Vector( 0, 0, 0 ) else dir.normalize()
val dash = dir.multiply( dashSpeed ).add(Vector( 0.0, yBoost, 0.0 ))
p.velocity = dash
}, max( 0L, waitTicks ))
object : BukkitRunnable()
{
override fun run()
{
if (GroundDetector.isOnGround( player ))
{
player.world.createExplosion(
player.location,
explosionMultiplier.roundToInt().toFloat(),
false, true
)
val alivePlayers = plugin.getAlivePlayers().stream()
.filter { it != player }
.filter { it.location.distance( player.location ) <= defaultRadius }
.toList()
alivePlayers.forEach { nearby ->
nearby.damage( 6.0, player )
}
plugin.chatManager.sendMessage( player, "kits.blackPanther.messages.wakandaForever.hit", "{hit}" to alivePlayers.size.toString() )
this.cancel()
}
}
}.runTaskTimer( plugin, max( 0L, waitTicks ) + 5L, 5L )
}
private fun extraDamage(
player: Player
) {

View File

@@ -42,11 +42,12 @@ class BlitzcrankKit(
player: Player
) {
hotsItem = ItemBuilder( plugin, Material.HEART_OF_THE_SEA )
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.hots" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blitzcrank", "hots" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.add( hotsItem )
player.inventory.setItem( 0, hotsItem )
when( playStyle )
@@ -54,26 +55,26 @@ class BlitzcrankKit(
PlayStyle.DEFENSIVE ->
{
fishingRodItem = ItemBuilder( plugin, Material.FISHING_ROD )
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.fishing_rod" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blitzcrank", "fishingrod" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.add( fishingRodItem )
player.inventory.setItem( 1, fishingRodItem )
}
PlayStyle.OFFENSIVE ->
{
pufferfishItem = ItemBuilder( plugin, Material.PUFFERFISH )
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.pufferfish" ).content())
.name(plugin.messageConfig.data.getKitItemNames( "blitzcrank", "pufferfish" )!![ playStyle.name.lowercase() ]!!)
.unbreakable( true )
.hideAttributes()
.build()
items.add( pufferfishItem )
player.inventory.setItem( 1, pufferfishItem )
}
else -> {}
}
}
@@ -203,7 +204,7 @@ class BlitzcrankKit(
target.velocity = hookDirection
plugin.chatManager.sendMessage( player, "kits.blitzcrank.messages.hook.player", "{player}" to target.getDisplayName )
plugin.chatManager.sendMessage( player, "kits.blitzcrank.messages.hook.target" )
plugin.chatManager.sendMessage( target, "kits.blitzcrank.messages.hook.target" )
}
private fun stunNearby(