13
0
geforkt von Mirrors/Velocity

Fix implementation of #176

As @creeper123123321 noted on Discord, the javadoc specifies "Matches all {@link Player}s whose names start with the provided partial name.".

With the current implementation, if there were two online players named Notch and Notch2, only Notch would be returned as a singleton Collection. This PR fixes this behavior by removing the `exactMatch` code.
Dieser Commit ist enthalten in:
Hugo Manrique 2019-03-09 21:02:41 +01:00 committet von GitHub
Ursprung e2fa06fa17
Commit 8bb118022d
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -450,11 +450,6 @@ public class VelocityServer implements ProxyServer {
public Collection<Player> matchPlayer(String partialName) { public Collection<Player> matchPlayer(String partialName) {
Objects.requireNonNull(partialName); Objects.requireNonNull(partialName);
Optional<Player> exactMatch = getPlayer(partialName);
if (exactMatch.isPresent()) {
return Collections.singleton(exactMatch.get());
}
return getAllPlayers().stream().filter(p -> p.getUsername() return getAllPlayers().stream().filter(p -> p.getUsername()
.regionMatches(true, 0, partialName, 0, partialName.length())) .regionMatches(true, 0, partialName, 0, partialName.length()))
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -464,11 +459,6 @@ public class VelocityServer implements ProxyServer {
public Collection<RegisteredServer> matchServer(String partialName) { public Collection<RegisteredServer> matchServer(String partialName) {
Objects.requireNonNull(partialName); Objects.requireNonNull(partialName);
Optional<RegisteredServer> exactMatch = getServer(partialName);
if (exactMatch.isPresent()) {
return Collections.singleton(exactMatch.get());
}
return getAllServers().stream().filter(s -> s.getServerInfo().getName() return getAllServers().stream().filter(s -> s.getServerInfo().getName()
.regionMatches(true, 0, partialName, 0, partialName.length())) .regionMatches(true, 0, partialName, 0, partialName.length()))
.collect(Collectors.toList()); .collect(Collectors.toList());