Slightly changed player skills loading, hopefully removed NPEs

This commit is contained in:
Indyuce 2020-05-01 18:03:09 +02:00
parent b4b437a2ce
commit 1ce01d7be0
3 changed files with 9 additions and 4 deletions

View File

@ -260,7 +260,11 @@ public class PlayerClass extends PostLoadObject {
}
public boolean hasSkill(Skill skill) {
return skills.containsKey(skill.getId());
return hasSkill(skill.getId());
}
public boolean hasSkill(String id) {
return skills.containsKey(id);
}
public SkillInfo getSkill(Skill skill) {

View File

@ -80,7 +80,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
}
if (!isEmpty(result.getString("bound_skills")))
for (String skill : getJSONArray(result.getString("bound_skills")))
if (MMOCore.plugin.skillManager.has(skill))
if (data.getProfess().hasSkill(skill))
data.getBoundSkills().add(data.getProfess().getSkill(skill));
if (!isEmpty(result.getString("class_info"))) {
JsonObject object = parser.fromJson(result.getString("class_info"), JsonObject.class);

View File

@ -53,7 +53,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
config.getConfigurationSection("skill").getKeys(false).forEach(id -> data.setSkillLevel(id, config.getInt("skill." + id)));
if (config.contains("bound-skills"))
for (String id : config.getStringList("bound-skills"))
if (MMOCore.plugin.skillManager.has(id))
if (data.getProfess().hasSkill(id))
data.getBoundSkills().add(data.getProfess().getSkill(id));
/*
@ -116,7 +116,8 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
config.set("class-info." + key + ".attribute-points", info.getAttributePoints());
config.set("class-info." + key + ".attribute-realloc-points", info.getAttributeReallocationPoints());
info.getSkillKeys().forEach(skill -> config.set("class-info." + key + ".skill." + skill, info.getSkillLevel(skill)));
info.getAttributeKeys().forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute)));
info.getAttributeKeys()
.forEach(attribute -> config.set("class-info." + key + ".attribute." + attribute, info.getAttributeLevel(attribute)));
}
file.save();