From 8bb118022d91599ae6b7180730cb3ea827c58548 Mon Sep 17 00:00:00 2001 From: Hugo Manrique Date: Sat, 9 Mar 2019 21:02:41 +0100 Subject: [PATCH] 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. --- .../java/com/velocitypowered/proxy/VelocityServer.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index eb3ce47b4..9b126041d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -450,11 +450,6 @@ public class VelocityServer implements ProxyServer { public Collection matchPlayer(String partialName) { Objects.requireNonNull(partialName); - Optional exactMatch = getPlayer(partialName); - if (exactMatch.isPresent()) { - return Collections.singleton(exactMatch.get()); - } - return getAllPlayers().stream().filter(p -> p.getUsername() .regionMatches(true, 0, partialName, 0, partialName.length())) .collect(Collectors.toList()); @@ -464,11 +459,6 @@ public class VelocityServer implements ProxyServer { public Collection matchServer(String partialName) { Objects.requireNonNull(partialName); - Optional exactMatch = getServer(partialName); - if (exactMatch.isPresent()) { - return Collections.singleton(exactMatch.get()); - } - return getAllServers().stream().filter(s -> s.getServerInfo().getName() .regionMatches(true, 0, partialName, 0, partialName.length())) .collect(Collectors.toList());