Add new kit & register
This commit is contained in:
@@ -5,6 +5,8 @@ import club.mcscrims.speedhg.ability.AbilityContext
|
||||
import club.mcscrims.speedhg.game.GameManager
|
||||
import club.mcscrims.speedhg.kit.impl.AnchorKit
|
||||
import club.mcscrims.speedhg.kit.impl.ArmorerKit
|
||||
import club.mcscrims.speedhg.kit.impl.BlackPantherKit
|
||||
import club.mcscrims.speedhg.kit.impl.BlitzcrankKit
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
@@ -38,6 +40,22 @@ class KitManager(
|
||||
description = emptyList(),
|
||||
icon = Material.IRON_CHESTPLATE
|
||||
)
|
||||
|
||||
registerKit(
|
||||
kitClass = BlackPantherKit::class.java,
|
||||
id = "blackpanther",
|
||||
displayName = plugin.chatFormatter.format( "kits.blackpanther.displayName" ),
|
||||
description = emptyList(),
|
||||
icon = Material.DRAGON_EGG
|
||||
)
|
||||
|
||||
registerKit(
|
||||
kitClass = BlitzcrankKit::class.java,
|
||||
id = "blitzcrank",
|
||||
displayName = plugin.chatFormatter.format( "kits.blitzcrank.displayName" ),
|
||||
description = emptyList(),
|
||||
icon = Material.FISHING_ROD
|
||||
)
|
||||
}
|
||||
|
||||
fun registerKit(
|
||||
|
||||
@@ -50,6 +50,8 @@ class BlackPantherKit(
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
player.inventory.setItem( 0, blackDye )
|
||||
}
|
||||
|
||||
PlayStyle.OFFENSIVE ->
|
||||
@@ -65,6 +67,9 @@ class BlackPantherKit(
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
player.inventory.setItem( 0, blackDye )
|
||||
player.inventory.setItem( 1, blazePowder )
|
||||
}
|
||||
|
||||
else -> {}
|
||||
|
||||
233
src/main/kotlin/club/mcscrims/speedhg/kit/impl/BlitzcrankKit.kt
Normal file
233
src/main/kotlin/club/mcscrims/speedhg/kit/impl/BlitzcrankKit.kt
Normal file
@@ -0,0 +1,233 @@
|
||||
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.PlayStyle
|
||||
import club.mcscrims.speedhg.util.DirectionUtil
|
||||
import club.mcscrims.spigot.chat.getDisplayName
|
||||
import club.mcscrims.spigot.item.ItemBuilder
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.block.Action
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
import org.bukkit.event.player.PlayerInteractEvent
|
||||
import org.bukkit.event.player.PlayerMoveEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.potion.PotionEffect
|
||||
import org.bukkit.potion.PotionEffectType
|
||||
import org.bukkit.util.Vector
|
||||
|
||||
class BlitzcrankKit(
|
||||
id: String,
|
||||
displayName: Component,
|
||||
description: List<String>,
|
||||
icon: Material,
|
||||
playStyle: PlayStyle,
|
||||
plugin: SpeedHG,
|
||||
abilityContext: AbilityContext,
|
||||
gameManager: GameManager
|
||||
) : AbstractKit( id, displayName, description, icon, playStyle, plugin, abilityContext, gameManager ) {
|
||||
|
||||
override fun onSelect( player: Player ) {}
|
||||
|
||||
private lateinit var hotsItem: ItemStack
|
||||
private lateinit var fishingRodItem: ItemStack
|
||||
private lateinit var pufferfishItem: ItemStack
|
||||
|
||||
override fun onStart(
|
||||
player: Player
|
||||
) {
|
||||
hotsItem = ItemBuilder( plugin, Material.HEART_OF_THE_SEA )
|
||||
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.hots" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
player.inventory.setItem( 0, hotsItem )
|
||||
|
||||
when( playStyle )
|
||||
{
|
||||
PlayStyle.DEFENSIVE ->
|
||||
{
|
||||
fishingRodItem = ItemBuilder( plugin, Material.FISHING_ROD )
|
||||
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.fishing_rod" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
player.inventory.setItem( 1, fishingRodItem )
|
||||
}
|
||||
|
||||
PlayStyle.OFFENSIVE ->
|
||||
{
|
||||
pufferfishItem = ItemBuilder( plugin, Material.PUFFERFISH )
|
||||
.name(plugin.chatFormatter.format( "kits.blitzcrank.items.pufferfish" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
player.inventory.setItem( 1, pufferfishItem )
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHit( attacker: Player, victim: Player, event: EntityDamageByEntityEvent ) {}
|
||||
|
||||
override fun onDamaged( attacker: Player, victim: Player, event: EntityDamageByEntityEvent ) {}
|
||||
|
||||
// Ultimate
|
||||
private val ultimateDamage = plugin.kitConfig.data.blitzcrank[ "ultimate damage" ]!!
|
||||
private val ultimateRadius = plugin.kitConfig.data.blitzcrank[ "ultimate radius" ]!!
|
||||
private val ultimateStunDuration = plugin.kitConfig.data.blitzcrank[ "ultimate stun duration" ]!!
|
||||
|
||||
// Hook
|
||||
private val hookRange = plugin.kitConfig.data.blitzcrank[ "hook range" ]!!
|
||||
|
||||
// Stun
|
||||
private val stunHeight = plugin.kitConfig.data.blitzcrank[ "stun height" ]!!
|
||||
private val stunRadius = plugin.kitConfig.data.blitzcrank[ "stun radius" ]!!
|
||||
private val stunSlowDuration = plugin.kitConfig.data.blitzcrank[ "stun slow duration" ]!!
|
||||
|
||||
override fun onInteract(
|
||||
player: Player,
|
||||
event: PlayerInteractEvent
|
||||
) {
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
val action = event.action
|
||||
|
||||
if ( action != Action.RIGHT_CLICK_AIR &&
|
||||
action != Action.RIGHT_CLICK_BLOCK )
|
||||
return
|
||||
|
||||
val item = event.item ?: return
|
||||
|
||||
if ( item != hotsItem &&
|
||||
item != fishingRodItem &&
|
||||
item != pufferfishItem )
|
||||
return
|
||||
|
||||
when( item.type )
|
||||
{
|
||||
Material.HEART_OF_THE_SEA ->
|
||||
{
|
||||
val result = abilityContext.canUseAbility( player, "hots-blitzcrank", 15 )
|
||||
|
||||
if ( result.missingHits > 0 )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.missingHits", "{hits]" to result.missingHits.toString() )
|
||||
return
|
||||
}
|
||||
|
||||
ultimate( player, ultimateRadius )
|
||||
}
|
||||
|
||||
Material.FISHING_ROD ->
|
||||
{
|
||||
val result = abilityContext.canUseAbility( player, "hook-blitzcrank", 15 )
|
||||
|
||||
if ( result.missingHits > 0 )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.missingHits", "{hits]" to result.missingHits.toString() )
|
||||
return
|
||||
}
|
||||
|
||||
hookPlayer( player )
|
||||
}
|
||||
|
||||
Material.PUFFERFISH ->
|
||||
{
|
||||
val result = abilityContext.canUseAbility( player, "stun-blitzcrank", 15 )
|
||||
|
||||
if ( result.missingHits > 0 )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.missingHits", "{hits]" to result.missingHits.toString() )
|
||||
return
|
||||
}
|
||||
|
||||
stunNearby( player, stunRadius )
|
||||
}
|
||||
|
||||
else -> return
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMove( player: Player, event: PlayerMoveEvent ) {}
|
||||
|
||||
private fun ultimate(
|
||||
player: Player,
|
||||
radius: Double
|
||||
) {
|
||||
val nearbyPlayers = player.world.getNearbyPlayers( player.location, radius )
|
||||
|
||||
nearbyPlayers.forEach { nearby ->
|
||||
|
||||
nearby.damage( ultimateDamage, player )
|
||||
|
||||
nearby.addPotionEffect(PotionEffect(
|
||||
PotionEffectType.SLOWNESS,
|
||||
ultimateStunDuration.toInt() * 20,
|
||||
255,
|
||||
false,
|
||||
false,
|
||||
false
|
||||
))
|
||||
|
||||
plugin.chatManager.sendMessage( nearby, "kits.blitzcrank.messages.ultimate.target", "{player}" to player.getDisplayName )
|
||||
}
|
||||
|
||||
plugin.chatManager.sendMessage( player, "kits.blitzcrank.messages.ultimate.player", "{nearby}" to nearbyPlayers.size.toString() )
|
||||
}
|
||||
|
||||
private fun hookPlayer(
|
||||
player: Player
|
||||
) {
|
||||
val target = DirectionUtil.getTargetPlayerInLineOfSight( player, hookRange, 0.5 )
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.blitzcrank.messages.no_player_in_sight" )
|
||||
return
|
||||
}
|
||||
|
||||
val hookDirection = target.location.toVector().add( player.location.toVector() ).normalize()
|
||||
hookDirection.multiply( 1.0 )
|
||||
hookDirection.setY( 0.5 )
|
||||
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" )
|
||||
}
|
||||
|
||||
private fun stunNearby(
|
||||
player: Player,
|
||||
radius: Double
|
||||
) {
|
||||
val nearbyPlayers = player.world.getNearbyPlayers( player.location, radius )
|
||||
|
||||
nearbyPlayers.forEach { nearby ->
|
||||
|
||||
val velocity = nearby.velocity
|
||||
velocity.add(Vector( 0.0, stunHeight, 0.0 ))
|
||||
nearby.velocity = velocity
|
||||
|
||||
nearby.addPotionEffect(PotionEffect(
|
||||
PotionEffectType.SLOWNESS,
|
||||
20 * stunSlowDuration.toInt(),
|
||||
4, false, false, false
|
||||
))
|
||||
|
||||
plugin.chatManager.sendMessage( nearby, "kits.blitzcrank.messages.stun.target" )
|
||||
}
|
||||
|
||||
plugin.chatManager.sendMessage( player, "kits.blitzcrank.messages.stun.player", "{nearby}" to nearbyPlayers.size.toString() )
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user