Fix fetching advancements with invalid parents

(cherry picked from commit 2475452f73039165ce5cda35ba445acfebddb37f)
This commit is contained in:
Eclipse 2024-04-14 10:32:17 +00:00
parent a24f684123
commit bc6ded53fb
No known key found for this signature in database
GPG Key ID: 441A0B7FDD01D03A
1 changed files with 8 additions and 4 deletions

View File

@ -82,11 +82,15 @@ public class GeyserAdvancement {
this.rootId = this.advancement.getId();
} else {
// Go through our cache, and descend until we find the root ID
GeyserAdvancement advancement = advancementsCache.getStoredAdvancements().get(this.advancement.getParentId());
if (advancement.getParentId() == null) {
this.rootId = advancement.getId();
GeyserAdvancement parent = advancementsCache.getStoredAdvancements().get(this.advancement.getParentId());
if (parent == null) {
// Parent doesn't exist, is invalid, or couldn't be found for another reason
// So assuming there is no parent and this is the root
this.rootId = this.advancement.getId();
} else if (parent.getParentId() == null) {
this.rootId = parent.getId();
} else {
this.rootId = advancement.getRootId(advancementsCache);
this.rootId = parent.getRootId(advancementsCache);
}
}
}