SPIGOT-7949: Registering a new scoreboard objective with an empty display name throws a NPE

This commit is contained in:
md_5 2024-11-06 20:22:58 +11:00
parent 9b048cc845
commit ecf3dff0e2
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -55,7 +55,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "The name '%s' is longer than the limit of 32767 characters (%s)", name, name.length()); Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "The name '%s' is longer than the limit of 32767 characters (%s)", name, name.length());
Preconditions.checkArgument(board.getObjective(name) == null, "An objective of name '%s' already exists", name); Preconditions.checkArgument(board.getObjective(name) == null, "An objective of name '%s' already exists", name);
ScoreboardObjective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType), true, null); ScoreboardObjective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrEmpty(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType), true, null);
return new CraftObjective(this, objective); return new CraftObjective(this, objective);
} }