diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java index 42d23a87..6889cddb 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/PlayerData.java @@ -1202,6 +1202,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc if (boundSkills.containsKey(slot)) boundSkills.get(slot).unbind(); if (slot >= 0) { + //We apply the skill buffs associated with the slot to the skill. + profess.getSkillSlot(slot).getSkillBuffTriggers().forEach(skillBuffTrigger -> + skillBuffTrigger.apply(this,skill.getSkill().getHandler().getId())); + + if (skill.getSkill().getTrigger().isPassive()) { PassiveSkill passiveSkill = skill.toPassive(this); passiveSkill.register(mmoData); @@ -1213,6 +1218,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc } public void unbindSkill(int slot) { + //We remove the skill buffs associated with the slot from the skill that is . + profess.getSkillSlot(slot).getSkillBuffTriggers().forEach(skillBuffTrigger -> + skillBuffTrigger.remove(this,boundSkills.get(slot).getClassSkill().getSkill().getHandler().getId())); + BoundSkillInfo boundSkillInfo = boundSkills.remove(slot); boundSkillInfo.unbind(); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java index 852ead65..e191c921 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/player/profess/skillbinding/SkillSlot.java @@ -1,9 +1,12 @@ package net.Indyuce.mmocore.api.player.profess.skillbinding; +import io.lumine.mythic.lib.api.MMOLineConfig; +import net.Indyuce.mmocore.MMOCore; +import net.Indyuce.mmocore.api.quest.trigger.SkillBuffTrigger; import net.Indyuce.mmocore.skill.ClassSkill; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; - +import java.util.ArrayList; import java.util.List; public class SkillSlot { @@ -11,14 +14,18 @@ public class SkillSlot { private final String formula; private final String name; private final List lore; + + private final List skillBuffTriggers; + private Material item; - public SkillSlot(int slot, int modelData, String formula, String name, List lore, Material item) { + public SkillSlot(int slot, int modelData, String formula, String name, List lore, List skillBuffTriggers, Material item) { this.slot = slot; this.modelData = modelData; this.formula = formula; this.name = name; this.lore = lore; + this.skillBuffTriggers = skillBuffTriggers; this.item = item; } @@ -30,6 +37,12 @@ public class SkillSlot { if (section.contains("item")) this.item = Material.valueOf(section.getString("item")); this.modelData = section.getInt("model-data", 0); + skillBuffTriggers= new ArrayList<>(); + if(section.contains("skill-buffs")) + for(String skillBuff:section.getStringList("skill-buffs")) + if(skillBuff.startsWith("skill_buff")){ + skillBuffTriggers.add((SkillBuffTrigger) MMOCore.plugin.loadManager.loadTrigger(new MMOLineConfig(skillBuff))); + } } public int getSlot() { @@ -56,6 +69,10 @@ public class SkillSlot { return modelData; } + public List getSkillBuffTriggers() { + return skillBuffTriggers; + } + public boolean canPlaceSkill(ClassSkill classSkill) { return classSkill.getSkill().matchesFormula(formula); } diff --git a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java index 2c9753c4..a9de20cb 100644 --- a/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java +++ b/MMOCore-API/src/main/java/net/Indyuce/mmocore/api/quest/trigger/SkillBuffTrigger.java @@ -21,11 +21,10 @@ public class SkillBuffTrigger extends Trigger implements Removable { super(config); config.validateKeys("modifier"); config.validateKeys("amount"); - config.validateKeys("formula"); config.validateKeys("type"); amount = config.getDouble("amount"); String skillModifier = config.getString("modifier"); - String formula = config.getString("formula"); + String formula = config.getString("formula", "true"); List targetSkills = new ArrayList<>(); for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) { if (skill.matchesFormula(formula)) @@ -47,4 +46,18 @@ public class SkillBuffTrigger extends Trigger implements Removable { public void remove(PlayerData playerData) { skillBuff.unregister(playerData.getMMOPlayerData()); } + + + /** + * Used by skill slots to apply a skillBuff to a specific skill dynamically chosen . + */ + public void apply(PlayerData playerData, String skill) { + skillBuff.register(playerData.getMMOPlayerData(), skill); + } + /** + * Used by skill slots to remove a skillBuff from a specific skill dynamically chosen. + */ + public void remove(PlayerData playerData, String skill) { + skillBuff.unregister(playerData.getMMOPlayerData(), skill); + } }