The skill buffs associated to a slot will only trigger if the item bound matches the corresponding formula.

This commit is contained in:
Ka0rX 2023-04-06 12:08:06 +01:00
parent 8e93c83c0d
commit 6fd15725bb
2 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,7 @@ import net.Indyuce.mmocore.api.player.profess.skillbinding.SkillSlot;
import net.Indyuce.mmocore.api.player.social.FriendRequest;
import net.Indyuce.mmocore.api.player.stats.PlayerStats;
import net.Indyuce.mmocore.api.quest.PlayerQuests;
import net.Indyuce.mmocore.api.quest.trigger.SkillBuffTrigger;
import net.Indyuce.mmocore.api.quest.trigger.StatTrigger;
import net.Indyuce.mmocore.api.util.Closable;
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
@ -1214,13 +1215,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public void bindSkill(int slot, ClassSkill skill) {
Validate.notNull(skill, "Skill cannot be null");
//Unbinds the previous skill (Important for passive skills.
String skillId = skill.getSkill().getHandler().getId();
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()));
for (SkillBuffTrigger skillBuffTrigger : profess.getSkillSlot(slot).getSkillBuffTriggers())
if (skillBuffTrigger.getTargetSkills().contains(skillId))
skillBuffTrigger.apply(this, skill.getSkill().getHandler().getId());
if (skill.getSkill().getTrigger().isPassive()) {
PassiveSkill passiveSkill = skill.toPassive(this);

View File

@ -37,6 +37,11 @@ public class SkillBuffTrigger extends Trigger implements Removable {
skillBuff = new SkillBuff(buffKey, skillModifier, targetSkills, amount, ModifierType.valueOf(type));
}
public List<String> getTargetSkills() {
return skillBuff.getSkills();
}
@Override
public void apply(PlayerData player) {
if (player.getMMOPlayerData().getSkillBuffMap().hasSkillBuff(buffKey)) {
@ -58,6 +63,7 @@ public class SkillBuffTrigger extends Trigger implements Removable {
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.
*/