forked from Upstream/mmocore
Added the needs-bound
option in class skills section in order to set which passive skills need to be bound and which don't.
This commit is contained in:
parent
2b6f00d7fa
commit
df78c21aa3
@ -103,14 +103,11 @@ public class PlayerStats {
|
||||
*/
|
||||
final PassiveSkillMap skillMap = data.getMMOPlayerData().getPassiveSkillMap();
|
||||
|
||||
if (!MMOCore.plugin.configManager.passiveSkillNeedBound) {
|
||||
skillMap.removeModifiers("MMOCorePassiveSkill");
|
||||
data.getProfess().getSkills()
|
||||
.stream()
|
||||
.filter((classSkill) -> classSkill.getSkill().getTrigger().isPassive() && data.hasUnlocked(classSkill) && data.hasUnlockedLevel(classSkill))
|
||||
.forEach(classSkill -> skillMap.addModifier(classSkill.toPassive(data)));
|
||||
|
||||
}
|
||||
skillMap.removeModifiers("MMOCorePassiveSkillNotBound");
|
||||
data.getProfess().getSkills()
|
||||
.stream()
|
||||
.filter((classSkill) -> !classSkill.needsBound()&&classSkill.getSkill().getTrigger().isPassive() && data.hasUnlocked(classSkill) && data.hasUnlockedLevel(classSkill))
|
||||
.forEach(classSkill -> skillMap.addModifier(classSkill.toPassive(data)));
|
||||
|
||||
// This updates the player's class SCRIPTS
|
||||
skillMap.removeModifiers("MMOCoreClassScript");
|
||||
|
@ -20,7 +20,7 @@ import java.util.*;
|
||||
public class ClassSkill implements CooldownObject, Unlockable {
|
||||
private final RegisteredSkill skill;
|
||||
private final int unlockLevel, maxSkillLevel;
|
||||
private final boolean unlockedByDefault;
|
||||
private final boolean unlockedByDefault, needsBound;
|
||||
private final Map<String, LinearValue> parameters = new HashMap<>();
|
||||
|
||||
/**
|
||||
@ -37,10 +37,15 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
}
|
||||
|
||||
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault) {
|
||||
this(skill, unlockLevel, maxSkillLevel, unlockedByDefault, MMOCore.plugin.configManager.passiveSkillNeedBound);
|
||||
}
|
||||
|
||||
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault, boolean needsBound) {
|
||||
this.skill = skill;
|
||||
this.unlockLevel = unlockLevel;
|
||||
this.maxSkillLevel = maxSkillLevel;
|
||||
this.unlockedByDefault = unlockedByDefault;
|
||||
this.needsBound = needsBound;
|
||||
for (String param : skill.getHandler().getParameters())
|
||||
this.parameters.put(param, skill.getParameterInfo(param));
|
||||
}
|
||||
@ -50,6 +55,7 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
unlockLevel = config.getInt("level");
|
||||
maxSkillLevel = config.getInt("max-level");
|
||||
unlockedByDefault = config.getBoolean("unlocked-by-default", true);
|
||||
needsBound = config.getBoolean("needs-bound", MMOCore.plugin.configManager.passiveSkillNeedBound);
|
||||
for (String param : skill.getHandler().getParameters()) {
|
||||
LinearValue defaultValue = skill.getParameterInfo(param);
|
||||
this.parameters.put(param, config.isConfigurationSection(param) ? readLinearValue(defaultValue, config.getConfigurationSection(param)) : defaultValue);
|
||||
@ -78,6 +84,10 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
return unlockedByDefault;
|
||||
}
|
||||
|
||||
public boolean needsBound() {
|
||||
return needsBound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlockNamespacedKey() {
|
||||
return "skill:" + skill.getHandler().getId().toLowerCase();
|
||||
@ -90,18 +100,17 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
playerData.unbindSkill(slot);
|
||||
});
|
||||
//Update the stats to remove the passive skill if it is locked
|
||||
if (!MMOCore.plugin.configManager.passiveSkillNeedBound && getSkill().getTrigger().isPassive())
|
||||
if (!needsBound && getSkill().getTrigger().isPassive())
|
||||
playerData.getStats().updateStats();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenUnlocked(PlayerData playerData) {
|
||||
if (!MMOCore.plugin.configManager.passiveSkillNeedBound && getSkill().getTrigger().isPassive())
|
||||
if (!needsBound && getSkill().getTrigger().isPassive())
|
||||
playerData.getStats().updateStats();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Skill modifiers are now called parameters.
|
||||
*/
|
||||
@ -109,6 +118,7 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
public void addModifier(String modifier, LinearValue linear) {
|
||||
addParameter(modifier, linear);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can only override default parameters and
|
||||
* will throw an error when trying to define non existing modifiers
|
||||
@ -165,7 +175,8 @@ public class ClassSkill implements CooldownObject, Unlockable {
|
||||
*/
|
||||
public PassiveSkill toPassive(PlayerData caster) {
|
||||
Validate.isTrue(skill.getTrigger().isPassive(), "Skill is active");
|
||||
return new PassiveSkill("MMOCorePassiveSkill", toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
|
||||
//MMOCorePassiveSkillNotBound to identify passive skills that don't need to be bound
|
||||
return new PassiveSkill("MMOCorePassiveSkill" + (!needsBound ? "NotBound" : ""), toCastable(caster), EquipmentSlot.OTHER, ModifierSource.OTHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,7 +33,7 @@ public class BoundSkillInfo implements Closable {
|
||||
if (skillModifierTrigger.getTargetSkills().contains(classSkill.getSkill().getHandler()))
|
||||
skillModifierTrigger.apply(playerData, classSkill.getSkill().getHandler());
|
||||
|
||||
if (classSkill.getSkill().getTrigger().isPassive()) {
|
||||
if (classSkill.getSkill().getTrigger().isPassive()&& classSkill.needsBound()) {
|
||||
registered = classSkill.toPassive(playerData);
|
||||
registered.register(playerData.getMMOPlayerData());
|
||||
} else registered = null;
|
||||
@ -64,7 +64,7 @@ public class BoundSkillInfo implements Closable {
|
||||
open = false;
|
||||
|
||||
// Unregister skill if passive
|
||||
if (isPassive()) registered.unregister(playerData.getMMOPlayerData());
|
||||
if (isPassive()&& classSkill.needsBound()) registered.unregister(playerData.getMMOPlayerData());
|
||||
|
||||
// Remove skill buffs associated to the slot
|
||||
skillSlot.getSkillModifierTriggers().forEach(skillBuffTrigger -> skillBuffTrigger.remove(playerData, classSkill.getSkill().getHandler()));
|
||||
|
@ -222,8 +222,11 @@ death-exp-loss:
|
||||
# Maximum number of skill slots. This means that you cannot unlock more than X skill slots.
|
||||
max-skill-slots: 8
|
||||
|
||||
|
||||
# When set to true, passive skills must be bound in order to take effect.
|
||||
# When set to false, unlocked skills will take effect right away.
|
||||
# This is only the default behavior for skills but can be overridden by specifying true/false to
|
||||
# the needs-bound field in the class skills section.
|
||||
passive-skill-need-bound: true
|
||||
|
||||
# Set this to true to allow players in
|
||||
|
Loading…
Reference in New Issue
Block a user