Skip to content

Commit

Permalink
Ignore unregistered skills when loading user file
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Nov 15, 2023
1 parent 510dac2 commit 6c23370
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ private SkillLevelMaps loadSkills(ConfigurationNode node) {
// Load each skill section
node.childrenMap().forEach((skillName, skillNode) -> {
NamespacedId skillId = NamespacedId.fromString(skillName.toString());
Skill skill = plugin.getSkillRegistry().get(skillId);

Skill skill = plugin.getSkillRegistry().getOrNull(skillId);
if (skill == null) return;

int level = skillNode.node("level").getInt();
double xp = skillNode.node("xp").getDouble();

levelsMap.put(skill, level);
xpMap.put(skill, xp);
});
Expand All @@ -110,7 +111,8 @@ private Map<String, StatModifier> loadStatModifiers(ConfigurationNode node) {

if (name != null && statName != null) {
NamespacedId statId = NamespacedId.fromString(statName);
Stat stat = plugin.getStatRegistry().get(statId);
Stat stat = plugin.getStatRegistry().getOrNull(statId);
if (stat == null) return;

StatModifier statModifier = new StatModifier(name, stat, value);
statModifiers.put(name, statModifier);
Expand All @@ -128,7 +130,8 @@ private Map<String, TraitModifier> loadTraitModifiers(ConfigurationNode node) {

if (name != null && traitName != null) {
NamespacedId traitId = NamespacedId.fromString(traitName);
Trait trait = plugin.getTraitRegistry().get(traitId);
Trait trait = plugin.getTraitRegistry().getOrNull(traitId);
if (trait == null) return;

TraitModifier traitModifier = new TraitModifier(name, trait, value);
traitModifiers.put(name, traitModifier);
Expand Down

0 comments on commit 6c23370

Please sign in to comment.