Add new kits & recraft nerf
This commit is contained in:
@@ -4,6 +4,7 @@ import club.mcscrims.speedhg.SpeedHG
|
||||
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 net.kyori.adventure.text.Component
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
@@ -29,6 +30,14 @@ class KitManager(
|
||||
description = emptyList(),
|
||||
icon = Material.ANVIL
|
||||
)
|
||||
|
||||
registerKit(
|
||||
kitClass = ArmorerKit::class.java,
|
||||
id = "armorer",
|
||||
displayName = plugin.chatFormatter.format( "kits.armorer.displayName" ),
|
||||
description = emptyList(),
|
||||
icon = Material.IRON_CHESTPLATE
|
||||
)
|
||||
}
|
||||
|
||||
fun registerKit(
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.bukkit.event.player.PlayerInteractEvent
|
||||
import org.bukkit.event.player.PlayerMoveEvent
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.metadata.FixedMetadataValue
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class AnchorKit(
|
||||
id: String,
|
||||
@@ -33,12 +35,10 @@ class AnchorKit(
|
||||
|
||||
private lateinit var anvilItem: ItemStack
|
||||
|
||||
private var anvilPlaced: Boolean = false
|
||||
|
||||
private val extraDamage: Double = plugin.kitConfig.data.anchor[ "offensive extra damage" ]!!
|
||||
|
||||
private val radius = if ( playStyle == PlayStyle.DEFENSIVE ) 7.5 else 5.0
|
||||
private lateinit var anvilLoc: Location
|
||||
private val anvilList = ConcurrentHashMap<UUID, Location>()
|
||||
|
||||
override fun onSelect( player: Player ) {}
|
||||
|
||||
@@ -62,7 +62,7 @@ class AnchorKit(
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
if ( !anvilPlaced )
|
||||
if (!anvilList.contains( attacker.uniqueId ))
|
||||
return
|
||||
|
||||
if ( playStyle != PlayStyle.OFFENSIVE )
|
||||
@@ -79,7 +79,7 @@ class AnchorKit(
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
if ( !anvilPlaced )
|
||||
if (!anvilList.contains( attacker.uniqueId ))
|
||||
return
|
||||
|
||||
victim.velocity.setX( 0.0 )
|
||||
@@ -115,7 +115,7 @@ class AnchorKit(
|
||||
return
|
||||
}
|
||||
|
||||
if ( anvilPlaced )
|
||||
if (anvilList.contains( player.uniqueId ))
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.anchor.messages.alreadyActivated" )
|
||||
return
|
||||
@@ -129,18 +129,18 @@ class AnchorKit(
|
||||
return
|
||||
}
|
||||
|
||||
anvilLoc = eyeLocation.toBlockLocation()
|
||||
val anvilLoc = eyeLocation.toBlockLocation()
|
||||
anvilLoc.add( 0.0, 1.0, 0.0 )
|
||||
|
||||
anvilLoc.block.type = Material.ANVIL
|
||||
anvilLoc.block.setMetadata( KitMetaData.IS_ANVIL.getKey(), FixedMetadataValue( plugin, true ))
|
||||
|
||||
anvilPlaced = true
|
||||
anvilList[ player.uniqueId ]= anvilLoc
|
||||
|
||||
plugin.schedulerManager.runLater( 20 * 30L ) {
|
||||
if ( anvilPlaced )
|
||||
if (anvilList.contains( player.uniqueId ))
|
||||
{
|
||||
anvilPlaced = false
|
||||
anvilList.remove( player.uniqueId )
|
||||
anvilLoc.block.type = Material.AIR
|
||||
anvilLoc.block.removeMetadata( KitMetaData.IS_ANVIL.getKey(), plugin )
|
||||
}
|
||||
@@ -154,8 +154,8 @@ class AnchorKit(
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
if ( !anvilPlaced )
|
||||
return
|
||||
val anvilLoc = anvilList[ player.uniqueId ]
|
||||
?: return
|
||||
|
||||
if (player.location.distance( anvilLoc ) <= radius )
|
||||
return
|
||||
|
||||
114
src/main/kotlin/club/mcscrims/speedhg/kit/impl/ArmorerKit.kt
Normal file
114
src/main/kotlin/club/mcscrims/speedhg/kit/impl/ArmorerKit.kt
Normal file
@@ -0,0 +1,114 @@
|
||||
package club.mcscrims.speedhg.kit.impl
|
||||
|
||||
import club.mcscrims.speedhg.SpeedHG
|
||||
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 net.kyori.adventure.text.Component
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.Sound
|
||||
import org.bukkit.Statistic
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
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
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class ArmorerKit(
|
||||
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 ) {
|
||||
|
||||
private val killsUntilNew: Double = plugin.kitConfig.data.armorer[ "kills until new armor" ]!!
|
||||
|
||||
override fun onSelect( player: Player ) {}
|
||||
|
||||
override fun onStart( player: Player ) {}
|
||||
|
||||
override fun onHit(
|
||||
attacker: Player,
|
||||
victim: Player,
|
||||
event: EntityDamageByEntityEvent
|
||||
) {
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
if ( victim.health > 0.0 )
|
||||
return
|
||||
|
||||
val kills = attacker.getStatistic( Statistic.PLAYER_KILLS )
|
||||
|
||||
if (( kills.toDouble() / killsUntilNew ) % 2 != 0.0 )
|
||||
return
|
||||
|
||||
upgradeArmor( attacker, kills )
|
||||
attacker.playSound( attacker, Sound.BLOCK_NOTE_BLOCK_PLING, 1f, 1f )
|
||||
}
|
||||
|
||||
override fun onDamaged( attacker: Player, victim: Player, event: EntityDamageByEntityEvent ) {}
|
||||
|
||||
override fun onInteract( player: Player, event: PlayerInteractEvent ) {}
|
||||
|
||||
override fun onMove( player: Player, event: PlayerMoveEvent ) {}
|
||||
|
||||
private fun upgradeArmor(
|
||||
player: Player,
|
||||
killCount: Int
|
||||
) {
|
||||
val kills = killsUntilNew.roundToInt()
|
||||
|
||||
val armorType = when( killCount / kills )
|
||||
{
|
||||
1, 2 -> ArmorType.LEATHER
|
||||
3, 4 -> ArmorType.CHAINMAIL
|
||||
5, 6 -> ArmorType.GOLD
|
||||
7, 8 -> ArmorType.IRON
|
||||
else -> return
|
||||
}
|
||||
|
||||
val enchanted = ( killCount / kills ) % 2 == 0
|
||||
|
||||
val armor = createArmor( armorType, enchanted )
|
||||
player.inventory.armorContents = arrayOf( null, armor[0], null, armor[1] )
|
||||
|
||||
if ( !enchanted )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.armorer.messages.upgrade.normal", "{armorType}" to armorType.name )
|
||||
return
|
||||
}
|
||||
|
||||
plugin.chatManager.sendMessage( player, "kits.armorer.upgrade.enchanted" )
|
||||
}
|
||||
|
||||
private fun createArmor(
|
||||
type: ArmorType,
|
||||
enchanted: Boolean
|
||||
) = listOf(
|
||||
ItemStack( type.materialChestplate ).apply {
|
||||
if ( enchanted ) addEnchantment( Enchantment.PROTECTION, 1 )
|
||||
},
|
||||
ItemStack( type.materialBoots ).apply {
|
||||
if ( enchanted ) addEnchantment( Enchantment.PROTECTION, 1 )
|
||||
}
|
||||
)
|
||||
|
||||
enum class ArmorType(
|
||||
val materialChestplate: Material,
|
||||
val materialBoots: Material
|
||||
) {
|
||||
LEATHER( Material.LEATHER_CHESTPLATE, Material.LEATHER_BOOTS ),
|
||||
CHAINMAIL( Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_BOOTS ),
|
||||
GOLD( Material.GOLDEN_CHESTPLATE, Material.GOLDEN_BOOTS ),
|
||||
IRON( Material.IRON_CHESTPLATE, Material.IRON_BOOTS )
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
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 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.metadata.FixedMetadataValue
|
||||
|
||||
class BlackPantherKit(
|
||||
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 ) {
|
||||
|
||||
private lateinit var blackDye: ItemStack
|
||||
private lateinit var blazePowder: ItemStack
|
||||
|
||||
private val extraDamageAddition = plugin.kitConfig.data.blackPanther[ "extra damage on top" ]!!
|
||||
private val defaultRadius = plugin.kitConfig.data.blackPanther[ "default hit radius" ]!!
|
||||
private val explosionMultiplier = plugin.kitConfig.data.blackPanther[ "explosion multiplier" ]!!
|
||||
|
||||
override fun onSelect( player: Player ) {}
|
||||
|
||||
override fun onStart(
|
||||
player: Player
|
||||
) {
|
||||
when( playStyle )
|
||||
{
|
||||
PlayStyle.DEFENSIVE ->
|
||||
{
|
||||
blackDye = ItemBuilder( plugin, Material.BLACK_DYE )
|
||||
.name(plugin.chatFormatter.format( "kits.anchor.items.blackDye.${playStyle.name.lowercase()}" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
}
|
||||
|
||||
PlayStyle.OFFENSIVE ->
|
||||
{
|
||||
blackDye = ItemBuilder( plugin, Material.BLACK_DYE )
|
||||
.name(plugin.chatFormatter.format( "kits.anchor.items.blackDye.${playStyle.name.lowercase()}" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
|
||||
blazePowder = ItemBuilder( plugin, Material.BLAZE_POWDER )
|
||||
.name(plugin.chatFormatter.format( "kits.anchor.items.blazePowder" ).content())
|
||||
.unbreakable( true )
|
||||
.hideAttributes()
|
||||
.build()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHit(
|
||||
attacker: Player,
|
||||
victim: Player,
|
||||
event: EntityDamageByEntityEvent
|
||||
) {
|
||||
if ( !gameManager.isRunning() )
|
||||
return
|
||||
|
||||
if (!attacker.hasMetadata( KitMetaData.BP_EXTRA_DAMAGE.getKey() ))
|
||||
return
|
||||
|
||||
event.damage += extraDamageAddition
|
||||
}
|
||||
|
||||
override fun onDamaged( attacker: Player, victim: Player, event: EntityDamageByEntityEvent ) {}
|
||||
|
||||
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 != blackDye &&
|
||||
item != blazePowder )
|
||||
return
|
||||
|
||||
event.isCancelled = true
|
||||
|
||||
when( item.type )
|
||||
{
|
||||
Material.BLACK_DYE ->
|
||||
{
|
||||
val result = abilityContext.canUseAbility( player, "blackDye-blackPanther", 15 )
|
||||
|
||||
if ( result.missingHits > 0 )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.missingHits", "{hits]" to result.missingHits.toString() )
|
||||
return
|
||||
}
|
||||
|
||||
if ( playStyle == PlayStyle.DEFENSIVE )
|
||||
{
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Material.BLAZE_POWDER ->
|
||||
{
|
||||
val result = abilityContext.canUseAbility( player, "blazePowder-blackPanther", 15 )
|
||||
|
||||
if ( result.missingHits > 0 )
|
||||
{
|
||||
plugin.chatManager.sendMessage( player, "kits.missingHits", "{hits]" to result.missingHits.toString() )
|
||||
return
|
||||
}
|
||||
|
||||
extraDamage( player )
|
||||
}
|
||||
|
||||
else -> return
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMove( player: Player, event: PlayerMoveEvent ) {}
|
||||
|
||||
private fun extraDamage(
|
||||
player: Player
|
||||
) {
|
||||
player.setMetadata( KitMetaData.BP_EXTRA_DAMAGE.getKey(), FixedMetadataValue( plugin, true ))
|
||||
plugin.chatManager.sendMessage( player, "kits.blackPanther.messages.extraDamage.activated" )
|
||||
|
||||
plugin.schedulerManager.runLater( 12 * 30L ) {
|
||||
|
||||
player.removeMetadata( KitMetaData.BP_EXTRA_DAMAGE.getKey(), plugin )
|
||||
plugin.chatManager.sendMessage( player, "kits.blackPanther.messages.extraDamage.deactivated" )
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user