9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2025-12-31 04:46:31 +00:00

Added attack speed extension

This commit is contained in:
Auxilor
2021-10-05 19:04:51 +01:00
parent 37423f5174
commit 2d42baf5b0
7 changed files with 73 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ abstract class Stat(
val key: NamespacedKey
val uuid: UUID
val config: Config
open val config: Config
lateinit var name: String
init {

View File

@@ -0,0 +1,7 @@
group 'com.willfp'
version '1.0.0'
description = 'Attack Speed Extension'
shadowJar {
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
}

View File

@@ -0,0 +1,14 @@
package com.willfp.ecoskills.attackspeed
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.extensions.Extension
class AttackSpeedMain(plugin: EcoPlugin) : Extension(plugin) {
override fun onEnable() {
// Do nothing
}
override fun onDisable() {
// Do nothing
}
}

View File

@@ -0,0 +1,27 @@
package com.willfp.ecoskills.attackspeed
import com.willfp.ecoskills.getStatLevel
import com.willfp.ecoskills.stats.Stat
import org.bukkit.attribute.Attribute
import org.bukkit.attribute.AttributeModifier
import org.bukkit.entity.Player
class StatAttackSpeed : Stat(
"attack_speed"
) {
override fun updateStatLevel(player: Player) {
val modifier = AttributeModifier(
this.uuid,
this.name,
(this.config.getDouble("percent-faster-per-level") * player.getStatLevel(this)) / 100.0,
AttributeModifier.Operation.MULTIPLY_SCALAR_1
)
val instance = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED) ?: return
instance.removeModifier(modifier)
plugin.scheduler.run {
instance.removeModifier(modifier)
instance.addModifier(modifier)
}
}
}

View File

@@ -0,0 +1,4 @@
name: Attack Speed
main: com.willfp.ecoskills.attackspeed.AttackSpeedMain
version: ${projectVersion}
author: Auxilor

View File

@@ -0,0 +1,15 @@
group 'com.willfp'
description = 'Extension Parent'
subprojects {
dependencies {
compileOnly project(":eco-core:core-plugin")
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
}
tasks.withType(Jar) {
destinationDirectory = file("$rootDir/bin/")
}
tasks.jar.enabled = false
}

View File

@@ -2,4 +2,8 @@ rootProject.name = 'EcoSkills'
// Core
include ':eco-core'
include ':eco-core:core-plugin'
include ':eco-core:core-plugin'
// Extensions
include ':eco-extensions'
include ':eco-extensions:attackspeed'