Skip to content

Commit 59e136a

Browse files
authored
Skip lookup of player names longer than 16 characters (#2328)
1 parent 494f500 commit 59e136a

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎worldguard-core/src/main/java/com/sk89q/worldguard/protection/util/DomainInputResolver.java‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
public class DomainInputResolver implements Callable<DefaultDomain> {
4444

4545
private static final Pattern GROUP_PATTERN = Pattern.compile("(?i)^[G]:(.+)$");
46+
private static final int MAX_PLAYER_NAME_LENGTH = 16;
4647

4748
/**
4849
* The policy for locating users.
@@ -119,9 +120,14 @@ public DefaultDomain call() throws UnresolvedNamesException {
119120
}
120121
}
121122

122-
if (!namesToQuery.isEmpty()) {
123+
// Paper rejects longer names with an exception, so leave them unresolved.
124+
List<String> validNames = namesToQuery.stream()
125+
.filter(name -> name.length() <= MAX_PLAYER_NAME_LENGTH)
126+
.toList();
127+
128+
if (!validNames.isEmpty()) {
123129
try {
124-
for (Profile profile : profileService.findAllByName(namesToQuery)) {
130+
for (Profile profile : profileService.findAllByName(validNames)) {
125131
namesToQuery.remove(profile.getName().toLowerCase());
126132
domain.addPlayer(profile.getUniqueId());
127133
}

0 commit comments

Comments
 (0)