Skip to content

Commit

Permalink
Fix skull profile missing error when opening leaderboard menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jan 6, 2025
1 parent e04c24a commit 716263b
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -59,15 +60,34 @@ public void build(MenuBuilder menu) {
if (t.item().getItemMeta() instanceof SkullMeta meta) {
if (VersionUtils.isAtLeastVersion(18, 1)) {
PlayerProfile profile = Bukkit.createPlayerProfile(value.id());
meta.setOwnerProfile(profile);
if (profile.isComplete()) {
meta.setOwnerProfile(profile);
} else {
profile.update()
.thenAcceptAsync(updated -> {
if (profile.isComplete()) {
meta.setOwnerProfile(updated);
t.item().setItemMeta(meta);
} else {
setLegacySkullPlayer(meta, value);
t.item().setItemMeta(meta);
}
}, r -> plugin.getScheduler().executeSync(r))
.orTimeout(4000, TimeUnit.MILLISECONDS)
.exceptionally(e -> null);
}
} else {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(value.id());
meta.setOwningPlayer(offlinePlayer);
setLegacySkullPlayer(meta, value);
}
t.item().setItemMeta(meta);
}
return t.item();
});
});
}

private void setLegacySkullPlayer(SkullMeta meta, SkillValue value) {
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(value.id());
meta.setOwningPlayer(offlinePlayer);
}
}

0 comments on commit 716263b

Please sign in to comment.