Skip to content

Commit

Permalink
Fix NullPointerException while updating leaderboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jun 28, 2024
1 parent 5205b68 commit 01fbf02
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void updateLeaderboardsSync() {
setSorting(true);
// Initialize lists
Map<Skill, List<SkillValue>> skillLeaderboards = new HashMap<>();
for (Skill skill : plugin.getSkillManager().getSkillValues()) {
for (Skill skill : plugin.getSkillRegistry().getValues()) {
skillLeaderboards.put(skill, new ArrayList<>());
}
List<SkillValue> powerLeaderboard = new ArrayList<>();
Expand Down Expand Up @@ -194,7 +194,7 @@ private void addOfflinePlayers(Map<Skill, List<SkillValue>> skillLb, List<SkillV

// Add to skill leaderboard
SkillValue skillValue = new SkillValue(state.uuid(), level, xp);
skillLb.get(skill).add(skillValue);
skillLb.computeIfAbsent(skill, k -> new ArrayList<>()).add(skillValue);

if (skill.isEnabled()) {
powerLevel += level;
Expand All @@ -213,7 +213,7 @@ private void addOfflinePlayers(Map<Skill, List<SkillValue>> skillLb, List<SkillV
private void sortLeaderboards(Map<Skill, List<SkillValue>> skillLb, List<SkillValue> powerLb, List<SkillValue> averageLb) {
LeaderboardSorter sorter = new LeaderboardSorter();
for (Skill skill : plugin.getSkillManager().getSkillValues()) {
skillLb.get(skill).sort(sorter);
skillLb.computeIfAbsent(skill, k -> new ArrayList<>()).sort(sorter);
}
powerLb.sort(sorter);
AverageSorter averageSorter = new AverageSorter();
Expand Down

0 comments on commit 01fbf02

Please sign in to comment.