Last cleanup

This commit is contained in:
Jules 2023-04-10 16:46:05 +02:00
parent 2c9a6773f5
commit c104c8230d
4 changed files with 21 additions and 19 deletions

View File

@ -44,7 +44,6 @@ import net.Indyuce.mmocore.player.CombatHandler;
import net.Indyuce.mmocore.player.Unlockable;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
import net.Indyuce.mmocore.skill.binding.SkillSlot;
import net.Indyuce.mmocore.skill.cast.SkillCastingHandler;
import net.Indyuce.mmocore.skilltree.IntegerCoordinates;
import net.Indyuce.mmocore.skilltree.NodeStatus;
@ -105,6 +104,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
@Deprecated
private final Set<String> waypoints = new HashSet<>();
private final Map<String, Integer> skills = new HashMap<>();
// TODO change it to an array....... Map<Integer, BoundSkillInfo> is just BoundSkillInfo[]
private final Map<Integer, BoundSkillInfo> boundSkills = new HashMap<>();
private final PlayerProfessions collectSkills = new PlayerProfessions(this);
private final PlayerAttributes attributes = new PlayerAttributes(this);
@ -1064,15 +1064,15 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
public void setSkillLevel(String skill, int level) {
skills.put(skill, level);
refreshBoundedSkill(skill);
refreshBoundSkill(skill);
}
public void resetSkillLevel(String skill) {
skills.remove(skill);
refreshBoundedSkill(skill);
refreshBoundSkill(skill);
}
public void refreshBoundedSkill(String skill) {
public void refreshBoundSkill(String skill) {
boundSkills.values().stream().filter(skillInfo -> skillInfo.getClassSkill().getSkill().getHandler().getId().equals(skill)).forEach(BoundSkillInfo::refresh);
}
@ -1142,6 +1142,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
return boundSkills.containsKey(slot);
}
@Nullable
public ClassSkill getBoundSkill(int slot) {
return boundSkills.containsKey(slot) ? boundSkills.get(slot).getClassSkill() : null;
}

View File

@ -32,7 +32,7 @@ public class CastableSkill extends Skill {
PlayerData playerData = PlayerData.get(skillMeta.getCaster().getData().getUniqueId());
boolean loud = !getTrigger().isSilent();
// If the caster has unlocked that skill
// Skill is not usable yet
if (!playerData.hasSkillUnlocked(skill)) {
if (loud) MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(playerData.getPlayer());
return false;

View File

@ -22,9 +22,6 @@ public class ClassSkill implements CooldownObject, Unlockable {
private final boolean unlockedByDefault;
private final Map<String, LinearValue> modifiers = new HashMap<>();
@Deprecated
private final Set<Condition> unlockConditions = new HashSet<>();
/**
* Class used to save information about skills IN A CLASS CONTEXT
* i.e at which level the skill can be unlocked, etc.

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmocore.skill.binding;
import io.lumine.mythic.lib.player.skill.PassiveSkill;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.skill.ClassSkill;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.UUID;
@ -10,17 +11,18 @@ import java.util.UUID;
public class BoundSkillInfo {
private final PlayerData playerData;
private final ClassSkill classSkill;
private UUID passiveSkillUUID;
private UUID passiveSkillId;
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData) {
this.classSkill = classSkill;
this.playerData = playerData;
}
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData, UUID passiveSkillUUID) {
public BoundSkillInfo(ClassSkill classSkill, PlayerData playerData, UUID passiveSkillId) {
this.classSkill = classSkill;
this.playerData = playerData;
this.passiveSkillUUID = passiveSkillUUID;
this.passiveSkillId = passiveSkillId;
}
/**
@ -32,19 +34,22 @@ public class BoundSkillInfo {
info.unbind();
PassiveSkill passiveSkill = classSkill.toPassive(playerData);
passiveSkill.register(playerData.getMMOPlayerData());
this.passiveSkillUUID = passiveSkill.getUniqueId();
this.passiveSkillId = passiveSkill.getUniqueId();
}
@NotNull
public ClassSkill getClassSkill() {
return classSkill;
}
@NotNull
public PlayerData getPlayerData() {
return playerData;
}
public UUID getPassiveSkillUUID() {
return passiveSkillUUID;
@NotNull
public UUID getPassiveSkillId() {
return passiveSkillId;
}
/**
@ -52,16 +57,15 @@ public class BoundSkillInfo {
*/
public void refresh() {
if (classSkill.getSkill().getTrigger().isPassive()) {
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillUUID);
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillId);
PassiveSkill passiveSkill = classSkill.toPassive(playerData);
passiveSkill.register(playerData.getMMOPlayerData());
this.passiveSkillUUID = passiveSkill.getUniqueId();
this.passiveSkillId = passiveSkill.getUniqueId();
}
}
public void unbind() {
if (classSkill.getSkill().getTrigger().isPassive()) {
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillUUID);
}
if (classSkill.getSkill().getTrigger().isPassive())
playerData.getMMOPlayerData().getPassiveSkillMap().removeModifier(passiveSkillId);
}
}