Skip to content

Commit 87461bd

Browse files
authored
Merge branch 'Sandertv:master' into master
2 parents 4d6e762 + b0dbda1 commit 87461bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

minecraft/protocol/login/data.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,13 @@ func (data IdentityData) Validate() error {
5353
if id, err := uuid.Parse(data.Identity); err != nil || id == uuid.Nil {
5454
return fmt.Errorf("UUID must be parseable as a valid UUID, but got %v", data.Identity)
5555
}
56-
if len(data.DisplayName) == 0 || len(data.DisplayName) > 15 {
57-
return fmt.Errorf("DisplayName must not be empty or longer than 15 characters, but got %v characters", len(data.DisplayName))
56+
nameLimit := 15
57+
if data.XUID == "" {
58+
// Non-authenticated clients can have up to 16 characters in their name.
59+
nameLimit = 16
60+
}
61+
if len(data.DisplayName) == 0 || len(data.DisplayName) > nameLimit {
62+
return fmt.Errorf("DisplayName must not be empty or longer than %d characters, but got %v characters", nameLimit, len(data.DisplayName))
5863
}
5964
if data.DisplayName[0] == ' ' || data.DisplayName[len(data.DisplayName)-1] == ' ' {
6065
return fmt.Errorf("DisplayName may not have a space as first/last character, but got %v", data.DisplayName)

0 commit comments

Comments
 (0)