MobSkillFactory throws exception instead of returning null

This commit is contained in:
P0nk
2022-09-07 19:25:30 +02:00
parent 319d65a0c3
commit df5159e34c
3 changed files with 6 additions and 8 deletions

View File

@@ -7327,9 +7327,7 @@ public class Character extends AbstractCharacterObject {
final long length = rs.getInt("length");
MobSkill ms = MobSkillFactory.getMobSkill(MobSkillType.from(skillid), skilllv);
if (ms != null) {
loadedDiseases.put(disease, new Pair<>(length, ms));
}
loadedDiseases.put(disease, new Pair<>(length, ms));
}
}
}

View File

@@ -58,7 +58,9 @@ public class MobSkillFactory {
readLock.unlock();
}
return loadMobSkill(type, level).orElse(null);
return loadMobSkill(type, level).orElseThrow(
() -> new IllegalArgumentException("No MobSkill exists for type %s, level %d".formatted(type, level))
);
}
private static Optional<MobSkill> loadMobSkill(final MobSkillType type, final int level) {