diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt index 0701a39..b7be814 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/Stat.kt @@ -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 { diff --git a/eco-extensions/attackspeed/build.gradle b/eco-extensions/attackspeed/build.gradle new file mode 100644 index 0000000..d7fde28 --- /dev/null +++ b/eco-extensions/attackspeed/build.gradle @@ -0,0 +1,7 @@ +group 'com.willfp' +version '1.0.0' +description = 'Attack Speed Extension' + +shadowJar { + archiveFileName = project.getDescription() + " v" + project.version + ".jar" +} \ No newline at end of file diff --git a/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/AttackSpeedMain.kt b/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/AttackSpeedMain.kt new file mode 100644 index 0000000..dbc7e2b --- /dev/null +++ b/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/AttackSpeedMain.kt @@ -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 + } +} \ No newline at end of file diff --git a/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/StatAttackSpeed.kt b/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/StatAttackSpeed.kt new file mode 100644 index 0000000..fdad039 --- /dev/null +++ b/eco-extensions/attackspeed/src/main/kotlin/com/willfp/ecoskills/attackspeed/StatAttackSpeed.kt @@ -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) + } + } +} \ No newline at end of file diff --git a/eco-extensions/attackspeed/src/main/resources/extension.yml b/eco-extensions/attackspeed/src/main/resources/extension.yml new file mode 100644 index 0000000..a343cb0 --- /dev/null +++ b/eco-extensions/attackspeed/src/main/resources/extension.yml @@ -0,0 +1,4 @@ +name: Attack Speed +main: com.willfp.ecoskills.attackspeed.AttackSpeedMain +version: ${projectVersion} +author: Auxilor \ No newline at end of file diff --git a/eco-extensions/build.gradle b/eco-extensions/build.gradle new file mode 100644 index 0000000..e1cfea7 --- /dev/null +++ b/eco-extensions/build.gradle @@ -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 +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index db25ec8..1b53d73 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,4 +2,8 @@ rootProject.name = 'EcoSkills' // Core include ':eco-core' -include ':eco-core:core-plugin' \ No newline at end of file +include ':eco-core:core-plugin' + +// Extensions +include ':eco-extensions' +include ':eco-extensions:attackspeed' \ No newline at end of file