Skip to content

Commit 5be4eb8

Browse files
committed
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.
1 parent a0a69b6 commit 5be4eb8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/world/bentobox/aoneblock/listeners/CheckPhase.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ protected boolean phaseRequirementsFail(@Nullable Player player, @NonNull Island
108108
return false;
109109
}
110110

111+
if (player == null) {
112+
// Minions cannot fulfill requirements
113+
return true;
114+
}
111115
return phase.getRequirements().stream()
112116
.anyMatch(r -> checkRequirement(r, User.getInstance(player), i, is, world));
113117
}
@@ -206,7 +210,8 @@ List<String> replacePlaceholders(@Nullable Player player, @NonNull String phaseN
206210
.map(l -> ((Level) l).getIslandLevel(addon.getOverWorld(), i.getOwner())).orElse(0L);
207211
double balance = addon.getAddonByName("Bank").map(b -> ((Bank) b).getBankManager().getBalance(i).getValue())
208212
.orElse(0D);
209-
double ecoBalance = addon.getPlugin().getVault()
213+
double ecoBalance = player == null ? 0D
214+
: addon.getPlugin().getVault()
210215
.map(v -> v.getBalance(User.getInstance(player), addon.getOverWorld())).orElse(0D);
211216

212217
return c.replace("[island]", i.getName() == null ? "" : i.getName())

0 commit comments

Comments
 (0)