Skip to content

Commit ecc2154

Browse files
committed
Fix NPE when getting contributor names
1 parent 8b7b2b2 commit ecc2154

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

src/main/java/xyz/holocons/mc/waypoints/Waypoint.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ public long getChunkKey() {
8585
}
8686

8787
public List<String> getContributorNames() {
88-
return contributors.stream().map(uniqueId -> Bukkit.getPlayer(uniqueId).getName()).toList();
88+
return contributors.stream().map(uniqueId -> {
89+
final var player = Bukkit.getPlayer(uniqueId);
90+
return player != null ? player.getName() : uniqueId.toString();
91+
}).toList();
8992
}
9093

9194
private static ItemStack getBannerItem(Location location) {
@@ -104,14 +107,9 @@ private static ItemStack getDisplayItem(Location location) {
104107
if (itemMeta.hasDisplayName()) {
105108
itemMeta.displayName(itemMeta.displayName().decoration(TextDecoration.ITALIC, false));
106109
}
107-
var vectorComponent = Component.text()
108-
.color(NamedTextColor.GRAY)
109-
.append(Component.text(location.getBlockX()))
110-
.append(Component.space())
111-
.append(Component.text(location.getBlockY()))
112-
.append(Component.space())
113-
.append(Component.text(location.getBlockZ()))
114-
.build();
110+
var vectorComponent = Component.text(
111+
String.format("%d %d %d", location.getBlockX(), location.getBlockY(), location.getBlockZ()),
112+
NamedTextColor.GRAY);
115113
var worldComponent = Component.text(location.getWorld().getName(), NamedTextColor.GRAY);
116114
itemMeta.lore(List.of(vectorComponent, worldComponent));
117115
itemStack.setItemMeta(itemMeta);

0 commit comments

Comments
 (0)