From 7ec1a1aa4efddd79477d6ef118958814e87ab5fe Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 5 Sep 2015 13:42:33 +1000 Subject: [PATCH] Fix / clarify behaviour of matchPlayer. --- api/src/main/java/net/md_5/bungee/api/ProxyServer.java | 8 ++++++-- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java index 4c191f25..11c5b685 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java @@ -284,11 +284,15 @@ public abstract class ProxyServer * Attempts to match any players with the given name, and returns a list of * all possible matches. * - * @param name the (partial) name to match + * The exact algorithm to use to match players is implementation specific, + * but in general you can expect this method to return player's whose names + * begin with the specified prefix. + * + * @param match the (partial) name to match * @return list of all possible players, singleton if there is an exact * match */ - public abstract Collection matchPlayer(String name); + public abstract Collection matchPlayer(String match); /** * Creates a new empty title configuration. In most cases you will want to diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 8fc2f882..795a015b 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -660,13 +660,13 @@ public class BungeeCord extends ProxyServer return Collections.singleton( exactMatch ); } - return Sets.newHashSet( Iterables.find( getPlayers(), new Predicate() + return Sets.newHashSet( Iterables.filter( getPlayers(), new Predicate() { @Override public boolean apply(ProxiedPlayer input) { - return ( input == null ) ? false : input.getName().toLowerCase().contains( partialName.toLowerCase() ); + return ( input == null ) ? false : input.getName().toLowerCase().startsWith( partialName.toLowerCase() ); } } ) ); }