Fix / clarify behaviour of matchPlayer.

This commit is contained in:
md_5 2015-09-05 13:42:33 +10:00
parent 59208aad86
commit 7ec1a1aa4e
2 changed files with 8 additions and 4 deletions

View File

@ -284,11 +284,15 @@ public abstract class ProxyServer
* Attempts to match any players with the given name, and returns a list of * Attempts to match any players with the given name, and returns a list of
* all possible matches. * 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 * @return list of all possible players, singleton if there is an exact
* match * match
*/ */
public abstract Collection<ProxiedPlayer> matchPlayer(String name); public abstract Collection<ProxiedPlayer> matchPlayer(String match);
/** /**
* Creates a new empty title configuration. In most cases you will want to * Creates a new empty title configuration. In most cases you will want to

View File

@ -660,13 +660,13 @@ public class BungeeCord extends ProxyServer
return Collections.singleton( exactMatch ); return Collections.singleton( exactMatch );
} }
return Sets.newHashSet( Iterables.find( getPlayers(), new Predicate<ProxiedPlayer>() return Sets.newHashSet( Iterables.filter( getPlayers(), new Predicate<ProxiedPlayer>()
{ {
@Override @Override
public boolean apply(ProxiedPlayer input) 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() );
} }
} ) ); } ) );
} }