9
0
mirror of https://github.com/Auxilor/Reforges.git synced 2025-12-26 18:39:19 +00:00

Added EcoSkills integration

This commit is contained in:
Auxilor
2021-10-05 09:39:26 +01:00
parent b3815ade98
commit bee0e7e91c
6 changed files with 71 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ version rootProject.version
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
compileOnly 'com.willfp:EcoSkills:1.4.0'
}
build.dependsOn publishToMavenLocal

View File

@@ -3,6 +3,7 @@ package com.willfp.reforges;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.eco.core.display.DisplayModule;
import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.eco.core.items.Items;
import com.willfp.reforges.commands.CommandReforge;
import com.willfp.reforges.commands.CommandReforges;
@@ -11,6 +12,7 @@ import com.willfp.reforges.config.TargetYml;
import com.willfp.reforges.display.ReforgesDisplay;
import com.willfp.reforges.effects.Effect;
import com.willfp.reforges.effects.Effects;
import com.willfp.reforges.integrations.ecoskills.EcoSkillsIntegration;
import com.willfp.reforges.reforges.Reforges;
import com.willfp.reforges.reforges.util.ReforgeArgParser;
import com.willfp.reforges.reforges.util.ReforgeEnableListeners;
@@ -108,6 +110,13 @@ public class ReforgesPlugin extends EcoPlugin {
return new ReforgesDisplay(this);
}
@Override
protected List<IntegrationLoader> loadIntegrationLoaders() {
return Arrays.asList(
new IntegrationLoader("EcoSkills", EcoSkillsIntegration.INSTANCE::load)
);
}
@Override
public String getMinimumEcoVersion() {
return "6.9.0";

View File

@@ -5,6 +5,7 @@ import com.willfp.reforges.ReforgesPlugin;
import com.willfp.reforges.reforges.util.Watcher;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
@@ -56,6 +57,16 @@ public abstract class Effect implements Listener, Watcher {
return UUID.nameUUIDFromBytes((this.id + index + Arrays.hashCode(extra)).getBytes());
}
/**
* Generate a NamespacedKey with a specified index.
*
* @param index The index.
* @return The NamespacedKey.
*/
protected NamespacedKey getNamespacedKey(final int index) {
return this.getPlugin().getNamespacedKeyFactory().create(this.id + "_" + index);
}
/**
* Handle application of a reforge containing this effect.
*

View File

@@ -0,0 +1,11 @@
package com.willfp.reforges.integrations.ecoskills
import com.willfp.reforges.effects.Effect
object EcoSkillsIntegration {
lateinit var ADD_STAT: Effect
fun load() {
ADD_STAT = EffectAddStat()
}
}

View File

@@ -0,0 +1,38 @@
package com.willfp.reforges.integrations.ecoskills
import com.willfp.eco.core.config.interfaces.JSONConfig
import com.willfp.ecoskills.api.EcoSkillsAPI
import com.willfp.ecoskills.api.modifier.PlayerStatModifier
import com.willfp.ecoskills.stats.Stats
import com.willfp.reforges.effects.Effect
import com.willfp.reforges.effects.getEffectAmount
import org.bukkit.entity.Player
class EffectAddStat : Effect("add_stat") {
private val api = EcoSkillsAPI.getInstance()
override fun handleEnable(
player: Player,
config: JSONConfig
) {
api.addStatModifier(
player,
PlayerStatModifier(
this.getNamespacedKey(player.getEffectAmount(this)),
Stats.getByID(config.getString("stat", false)) ?: Stats.WISDOM,
config.getInt("amount")
)
)
}
override fun handleDisable(player: Player) {
api.removeStatModifier(
player,
PlayerStatModifier(
this.getNamespacedKey(player.getEffectAmount(this)),
Stats.STRENGTH,
0
)
)
}
}

View File

@@ -10,6 +10,7 @@ depend:
- ProtocolLib
softdepend:
- Vault
- EcoSkills
libraries:
- 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'