Skip to content

Commit

Permalink
Minor NPE defensive code
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Nov 17, 2024
1 parent f48269b commit 9469b6f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/world/bentobox/level/PlaceholderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -111,7 +112,8 @@ String getRankName(World world, int rank, boolean weighted) {
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)
Expand Down

0 comments on commit 9469b6f

Please sign in to comment.