mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-26 20:55:54 +01:00
Merge pull request #76 from PikachuEXE/refactor/player-finder-find-exact-match-first
* Return a player with exact name match first when trying to partial match
This commit is contained in:
commit
0ebc32f40a
@ -9,8 +9,18 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerFinder {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param queryString String that contains part of player name
|
||||
* @return if there is a player with exact name (case insensitive), return it
|
||||
* else if there is a player with name which contains part of queryString, return it
|
||||
* else {@code null}
|
||||
*/
|
||||
public static Player findOnlinePlayerByPartialCaseInsensitiveNameMatch(String queryString) {
|
||||
Player target_online_player = null;
|
||||
Player target_online_player = findOnlinePlayerByExactCaseInsensitiveNameMatch(queryString);
|
||||
if (target_online_player != null) {
|
||||
return target_online_player;
|
||||
}
|
||||
|
||||
for (Player online_player : Bukkit.getOnlinePlayers()) {
|
||||
if (online_player.getName().toLowerCase().contains(queryString.toLowerCase())) {
|
||||
|
Loading…
Reference in New Issue
Block a user