Skip to content

Commit

Permalink
Fix for null players, i.e., minions at end of phase.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tastybento committed May 2, 2024
1 parent a0a69b6 commit 5be4eb8
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -206,7 +210,8 @@ List<String> 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())
Expand Down

0 comments on commit 5be4eb8

Please sign in to comment.