I am trying to get a Player's object from the specified name. What I have currently only works when the name doesn't contain a space. What am I doing wrong?
private Player getPlayerObjectFromName(String name) {
List<Player> players = getPlayers().filter(player -> player != null && player.getName().equalsIgnoreCase(name));
if (players != null) {
for (Player p : players) {
if (p.getName().equalsIgnoreCase(name)) {
return p;
}
}
}
return null;
}
Edit: So I figured out the issue. Player objects use (char) 160 as a space which is why I was never getting a match when testing a name with (char) 32 as its space.