From 9469b6f2f76d0ebae319aacf0262352e2d1dd822 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 17 Nov 2024 13:13:57 -0800 Subject: [PATCH] Minor NPE defensive code --- src/main/java/world/bentobox/level/PlaceholderManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/level/PlaceholderManager.java b/src/main/java/world/bentobox/level/PlaceholderManager.java index 886a1be..825ede9 100644 --- a/src/main/java/world/bentobox/level/PlaceholderManager.java +++ b/src/main/java/world/bentobox/level/PlaceholderManager.java @@ -2,6 +2,7 @@ package world.bentobox.level; import java.util.Collections; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.UUID; import java.util.stream.Collectors; @@ -111,7 +112,8 @@ public class PlaceholderManager { rank = Math.max(1, Math.min(rank, Level.TEN)); if (weighted) { return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L) - .findFirst().map(Island::getOwner).map(addon.getPlayers()::getName).orElse(""); + .findFirst().map(Island::getOwner).filter(Objects::nonNull).map(addon.getPlayers()::getName) + .orElse(""); } @Nullable UUID owner = addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)