From 5be4eb8c9135bfb03c11fabc82ff4a42d19d55ef Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 2 May 2024 16:08:10 -0700 Subject: [PATCH] Fix for null players, i.e., minions at end of phase. If a minion broke the block at the end of the phase, the NPEs would occur as the newer code to check requirements and do placeholders was assuming a real player. This change protects that. Note that minions cannot be used to progress past a phase if there are any restrictions on the level change. --- .../world/bentobox/aoneblock/listeners/CheckPhase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java b/src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java index 6423a345..491ed4d7 100644 --- a/src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java +++ b/src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java @@ -108,6 +108,10 @@ protected boolean phaseRequirementsFail(@Nullable Player player, @NonNull Island return false; } + if (player == null) { + // Minions cannot fulfill requirements + return true; + } return phase.getRequirements().stream() .anyMatch(r -> checkRequirement(r, User.getInstance(player), i, is, world)); } @@ -206,7 +210,8 @@ List replacePlaceholders(@Nullable Player player, @NonNull String phaseN .map(l -> ((Level) l).getIslandLevel(addon.getOverWorld(), i.getOwner())).orElse(0L); double balance = addon.getAddonByName("Bank").map(b -> ((Bank) b).getBankManager().getBalance(i).getValue()) .orElse(0D); - double ecoBalance = addon.getPlugin().getVault() + double ecoBalance = player == null ? 0D + : addon.getPlugin().getVault() .map(v -> v.getBalance(User.getInstance(player), addon.getOverWorld())).orElse(0D); return c.replace("[island]", i.getName() == null ? "" : i.getName())