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:
@@ -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 {
|
||||
|
||||
7
eco-extensions/attackspeed/build.gradle
Normal file
7
eco-extensions/attackspeed/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
group 'com.willfp'
|
||||
version '1.0.0'
|
||||
description = 'Attack Speed Extension'
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Attack Speed
|
||||
main: com.willfp.ecoskills.attackspeed.AttackSpeedMain
|
||||
version: ${projectVersion}
|
||||
author: Auxilor
|
||||
15
eco-extensions/build.gradle
Normal file
15
eco-extensions/build.gradle
Normal 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
|
||||
}
|
||||
@@ -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'
|
||||
Reference in New Issue
Block a user