SPIGOT-5863: Don't check colour in scoreboard length validation

This commit is contained in:
md_5 2020-06-28 08:58:26 +10:00
parent f2cbce30d9
commit 2a8482869d
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -38,7 +38,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
@Override @Override
public void setDisplayName(String displayName) throws IllegalStateException { public void setDisplayName(String displayName) throws IllegalStateException {
Validate.notNull(displayName, "Display name cannot be null"); Validate.notNull(displayName, "Display name cannot be null");
Validate.isTrue(displayName.length() <= 128, "Display name '" + displayName + "' is longer than the limit of 128 characters"); Validate.isTrue(ChatColor.stripColor(displayName).length() <= 128, "Display name '" + displayName + "' is longer than the limit of 128 characters");
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
team.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable team.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable
@ -54,7 +54,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
@Override @Override
public void setPrefix(String prefix) throws IllegalStateException, IllegalArgumentException { public void setPrefix(String prefix) throws IllegalStateException, IllegalArgumentException {
Validate.notNull(prefix, "Prefix cannot be null"); Validate.notNull(prefix, "Prefix cannot be null");
Validate.isTrue(prefix.length() <= 64, "Prefix '" + prefix + "' is longer than the limit of 64 characters"); Validate.isTrue(ChatColor.stripColor(prefix).length() <= 64, "Prefix '" + prefix + "' is longer than the limit of 64 characters");
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
team.setPrefix(CraftChatMessage.fromStringOrNull(prefix)); team.setPrefix(CraftChatMessage.fromStringOrNull(prefix));
@ -70,7 +70,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
@Override @Override
public void setSuffix(String suffix) throws IllegalStateException, IllegalArgumentException { public void setSuffix(String suffix) throws IllegalStateException, IllegalArgumentException {
Validate.notNull(suffix, "Suffix cannot be null"); Validate.notNull(suffix, "Suffix cannot be null");
Validate.isTrue(suffix.length() <= 64, "Suffix '" + suffix + "' is longer than the limit of 64 characters"); Validate.isTrue(ChatColor.stripColor(suffix).length() <= 64, "Suffix '" + suffix + "' is longer than the limit of 64 characters");
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
team.setSuffix(CraftChatMessage.fromStringOrNull(suffix)); team.setSuffix(CraftChatMessage.fromStringOrNull(suffix));