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

Finally got AttackSpeed release-ready with eco 6.11.0

This commit is contained in:
Auxilor
2021-10-12 12:24:18 +01:00
parent e89761d485
commit 4132e7c732
5 changed files with 49 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ allprojects {
}
dependencies {
compileOnly 'com.willfp:eco:6.8.1'
compileOnly 'com.willfp:eco:6.11.0'
compileOnly 'org.jetbrains:annotations:19.0.0'
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'

View File

@@ -0,0 +1,11 @@
package com.willfp.ecoskills.attackspeed;
import com.willfp.eco.core.PluginLike;
import com.willfp.eco.core.config.yaml.YamlBaseConfig;
import org.jetbrains.annotations.NotNull;
public class AttackSpeedConfig extends YamlBaseConfig {
public AttackSpeedConfig(@NotNull final PluginLike plugin) {
super("attackspeed", true, plugin);
}
}

View File

@@ -1,15 +1,20 @@
package com.willfp.ecoskills.attackspeed;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.ecoskills.stats.Stat;
import org.jetbrains.annotations.NotNull;
public class AttackSpeedMain extends Extension {
/**
* Attack Speed.
* The instance.
*/
public static final Stat ATTACK_SPEED = new StatAttackSpeed();
private static AttackSpeedMain instance;
/**
* attackspeed.yml.
*/
private Config config = new AttackSpeedConfig(this);
/**
* Create a new extension for a plugin.
@@ -18,15 +23,34 @@ public class AttackSpeedMain extends Extension {
*/
public AttackSpeedMain(@NotNull final EcoPlugin plugin) {
super(plugin);
instance = this;
}
@Override
protected void onEnable() {
new StatAttackSpeed();
}
@Override
protected void onDisable() {
}
/**
* Get attackspeed.yml.
*
* @return The config.
*/
public Config getConfig() {
return config;
}
/**
* Get instance.
*
* @return The instance.
*/
public static AttackSpeedMain getInstance() {
return instance;
}
}

View File

@@ -1,13 +1,11 @@
package com.willfp.ecoskills.attackspeed;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.yaml.YamlTransientConfig;
import com.willfp.ecoskills.api.EcoSkillsAPI;
import com.willfp.ecoskills.stats.Stat;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -22,7 +20,7 @@ public class StatAttackSpeed extends Stat {
@NotNull
@Override
public Config loadConfig() {
return new YamlTransientConfig(new YamlConfiguration());
return AttackSpeedMain.getInstance().getConfig();
}
@Override
@@ -30,7 +28,10 @@ public class StatAttackSpeed extends Stat {
AttributeModifier modifier = new AttributeModifier(
this.getUuid(),
this.getName(),
EcoSkillsAPI.getInstance().getStatLevel(player, this) / 100D,
(
this.config.getDouble("percent-faster-per-level")
* EcoSkillsAPI.getInstance().getStatLevel(player, this)
) / 100.0,
AttributeModifier.Operation.MULTIPLY_SCALAR_1
);

View File

@@ -0,0 +1,4 @@
name: '&#fcba03⚔ Attack Speed'
# The percent more speed to give for the attack speed attribute (internal in the game)
# for each level
percent-faster-per-level: 1