forked from Upstream/mmocore
Made it possible to have SkillBuffs associated to a SkillSlot.
This commit is contained in:
parent
de5bfd5ed1
commit
9e98cd0640
@ -1202,6 +1202,11 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
if (boundSkills.containsKey(slot))
|
if (boundSkills.containsKey(slot))
|
||||||
boundSkills.get(slot).unbind();
|
boundSkills.get(slot).unbind();
|
||||||
if (slot >= 0) {
|
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()) {
|
if (skill.getSkill().getTrigger().isPassive()) {
|
||||||
PassiveSkill passiveSkill = skill.toPassive(this);
|
PassiveSkill passiveSkill = skill.toPassive(this);
|
||||||
passiveSkill.register(mmoData);
|
passiveSkill.register(mmoData);
|
||||||
@ -1213,6 +1218,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void unbindSkill(int slot) {
|
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 boundSkillInfo = boundSkills.remove(slot);
|
||||||
boundSkillInfo.unbind();
|
boundSkillInfo.unbind();
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package net.Indyuce.mmocore.api.player.profess.skillbinding;
|
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 net.Indyuce.mmocore.skill.ClassSkill;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SkillSlot {
|
public class SkillSlot {
|
||||||
@ -11,14 +14,18 @@ public class SkillSlot {
|
|||||||
private final String formula;
|
private final String formula;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final List<String> lore;
|
private final List<String> lore;
|
||||||
|
|
||||||
|
private final List<SkillBuffTrigger> skillBuffTriggers;
|
||||||
|
|
||||||
private Material item;
|
private Material item;
|
||||||
|
|
||||||
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, Material item) {
|
public SkillSlot(int slot, int modelData, String formula, String name, List<String> lore, List<SkillBuffTrigger> skillBuffTriggers, Material item) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.modelData = modelData;
|
this.modelData = modelData;
|
||||||
this.formula = formula;
|
this.formula = formula;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lore = lore;
|
this.lore = lore;
|
||||||
|
this.skillBuffTriggers = skillBuffTriggers;
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +37,12 @@ public class SkillSlot {
|
|||||||
if (section.contains("item"))
|
if (section.contains("item"))
|
||||||
this.item = Material.valueOf(section.getString("item"));
|
this.item = Material.valueOf(section.getString("item"));
|
||||||
this.modelData = section.getInt("model-data", 0);
|
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() {
|
public int getSlot() {
|
||||||
@ -56,6 +69,10 @@ public class SkillSlot {
|
|||||||
return modelData;
|
return modelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SkillBuffTrigger> getSkillBuffTriggers() {
|
||||||
|
return skillBuffTriggers;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean canPlaceSkill(ClassSkill classSkill) {
|
public boolean canPlaceSkill(ClassSkill classSkill) {
|
||||||
return classSkill.getSkill().matchesFormula(formula);
|
return classSkill.getSkill().matchesFormula(formula);
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,10 @@ public class SkillBuffTrigger extends Trigger implements Removable {
|
|||||||
super(config);
|
super(config);
|
||||||
config.validateKeys("modifier");
|
config.validateKeys("modifier");
|
||||||
config.validateKeys("amount");
|
config.validateKeys("amount");
|
||||||
config.validateKeys("formula");
|
|
||||||
config.validateKeys("type");
|
config.validateKeys("type");
|
||||||
amount = config.getDouble("amount");
|
amount = config.getDouble("amount");
|
||||||
String skillModifier = config.getString("modifier");
|
String skillModifier = config.getString("modifier");
|
||||||
String formula = config.getString("formula");
|
String formula = config.getString("formula", "true");
|
||||||
List<String> targetSkills = new ArrayList<>();
|
List<String> targetSkills = new ArrayList<>();
|
||||||
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) {
|
for (RegisteredSkill skill : MMOCore.plugin.skillManager.getAll()) {
|
||||||
if (skill.matchesFormula(formula))
|
if (skill.matchesFormula(formula))
|
||||||
@ -47,4 +46,18 @@ public class SkillBuffTrigger extends Trigger implements Removable {
|
|||||||
public void remove(PlayerData playerData) {
|
public void remove(PlayerData playerData) {
|
||||||
skillBuff.unregister(playerData.getMMOPlayerData());
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user