Skip to content

Commit

Permalink
Make sure line text is never null
Browse files Browse the repository at this point in the history
  • Loading branch information
d0by1 committed Nov 20, 2022
1 parent 94db407 commit db3f084
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private String getText(@NonNull Player player, boolean update) {

// Update cache
if (update || string == null) {
string = text;
string = text == null ? "" : null;
// Parse placeholders.
if (!hasFlag(EnumFlag.DISABLE_PLACEHOLDERS)) {
string = parsePlaceholders(string, player, containsPlaceholders);
Expand Down Expand Up @@ -340,6 +340,12 @@ private String parsePlaceholders(@NonNull String string, @NonNull Player player,
.replace("{pages}", String.valueOf(hasParent() ? parent.getParent().size() : 1));
if (papi) {
string = PAPI.setPlaceholders(player, string);
if (string == null) {
// Some PlacehoderAPI placeholders might be replaced with null, so if the line content
// is just a single placeholder, there is a possibility that the line will be null. So,
// if that happens, just replace the null with an empty string.
string = "";
}
}
return string;
}
Expand Down

0 comments on commit db3f084

Please sign in to comment.