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