forked from Upstream/mmocore
Skill Unlocking Mechanic.
This commit is contained in:
parent
37bb719381
commit
aaa777267d
@ -534,20 +534,18 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the item is unlocked by the player
|
* @return If the item is unlocked by the player
|
||||||
* @deprecated Not used yet
|
* This is used for skills that can be locked & unlocked.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public boolean hasUnlocked(Unlockable unlockable) {
|
public boolean hasUnlocked(Unlockable unlockable) {
|
||||||
return unlockedItems.contains(unlockable.getUnlockNamespacedKey());
|
return unlockedItems.contains(unlockable.getUnlockNamespacedKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks an item for the player
|
* Unlocks an item for the player. This is mainly used to unlock skills.
|
||||||
*
|
*
|
||||||
* @return If the item was already unlocked when calling this method
|
* @return If the item was already unlocked when calling this method
|
||||||
* @deprecated Not used yet
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public boolean unlock(Unlockable unlockable) {
|
public boolean unlock(Unlockable unlockable) {
|
||||||
return unlockedItems.add(unlockable.getUnlockNamespacedKey());
|
return unlockedItems.add(unlockable.getUnlockNamespacedKey());
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,10 @@ public class SkillList extends EditableInventory {
|
|||||||
public SkillViewerInventory(PlayerData playerData, EditableInventory editable) {
|
public SkillViewerInventory(PlayerData playerData, EditableInventory editable) {
|
||||||
super(playerData, editable);
|
super(playerData, editable);
|
||||||
|
|
||||||
skills = new ArrayList<>(playerData.getProfess().getSkills());
|
skills = playerData.getProfess().getSkills()
|
||||||
|
.stream()
|
||||||
|
.filter((classSkill)->playerData.hasUnlocked(classSkill.getSkill()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
skillSlots = getEditable().getByFunction("skill").getSlots();
|
skillSlots = getEditable().getByFunction("skill").getSlots();
|
||||||
Validate.notNull(getEditable().getByFunction("slot"), "Your skill GUI config file is out-of-date, please regenerate it.");
|
Validate.notNull(getEditable().getByFunction("slot"), "Your skill GUI config file is out-of-date, please regenerate it.");
|
||||||
slotSlots = getEditable().getByFunction("slot").getSlots();
|
slotSlots = getEditable().getByFunction("slot").getSlots();
|
||||||
|
@ -17,6 +17,7 @@ import java.util.*;
|
|||||||
public class ClassSkill implements CooldownObject {
|
public class ClassSkill implements CooldownObject {
|
||||||
private final RegisteredSkill skill;
|
private final RegisteredSkill skill;
|
||||||
private final int unlockLevel, maxSkillLevel;
|
private final int unlockLevel, maxSkillLevel;
|
||||||
|
private final boolean unlockedByDefault;
|
||||||
private final Map<String, LinearValue> modifiers = new HashMap<>();
|
private final Map<String, LinearValue> modifiers = new HashMap<>();
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -32,10 +33,14 @@ public class ClassSkill implements CooldownObject {
|
|||||||
* It is also used by the MMOCore API to force players to cast abilities.
|
* It is also used by the MMOCore API to force players to cast abilities.
|
||||||
*/
|
*/
|
||||||
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel) {
|
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel) {
|
||||||
|
this(skill, unlockLevel, maxSkillLevel, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassSkill(RegisteredSkill skill, int unlockLevel, int maxSkillLevel, boolean unlockedByDefault) {
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
this.unlockLevel = unlockLevel;
|
this.unlockLevel = unlockLevel;
|
||||||
this.maxSkillLevel = maxSkillLevel;
|
this.maxSkillLevel = maxSkillLevel;
|
||||||
|
this.unlockedByDefault = unlockedByDefault;
|
||||||
for (String mod : skill.getHandler().getModifiers())
|
for (String mod : skill.getHandler().getModifiers())
|
||||||
this.modifiers.put(mod, skill.getModifierInfo(mod));
|
this.modifiers.put(mod, skill.getModifierInfo(mod));
|
||||||
}
|
}
|
||||||
@ -44,7 +49,7 @@ public class ClassSkill implements CooldownObject {
|
|||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
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);
|
||||||
for (String mod : skill.getHandler().getModifiers()) {
|
for (String mod : skill.getHandler().getModifiers()) {
|
||||||
LinearValue defaultValue = skill.getModifierInfo(mod);
|
LinearValue defaultValue = skill.getModifierInfo(mod);
|
||||||
this.modifiers.put(mod, config.isConfigurationSection(mod) ? readLinearValue(defaultValue, config.getConfigurationSection(mod)) : defaultValue);
|
this.modifiers.put(mod, config.isConfigurationSection(mod) ? readLinearValue(defaultValue, config.getConfigurationSection(mod)) : defaultValue);
|
||||||
@ -68,6 +73,10 @@ public class ClassSkill implements CooldownObject {
|
|||||||
return maxSkillLevel;
|
return maxSkillLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isUnlockedByDefault() {
|
||||||
|
return unlockedByDefault;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method can only override default modifiers and
|
* This method can only override default modifiers and
|
||||||
* will throw an error when trying to define non existing modifiers
|
* will throw an error when trying to define non existing modifiers
|
||||||
|
Loading…
Reference in New Issue
Block a user